1 /*
2  * Copyright (c) 2012-2018 The ANTLR Project. All rights reserved.
3  * Use of this file is governed by the BSD 3-clause license that
4  * can be found in the LICENSE.txt file in the project root.
5  */
6 
7 module antlr.v4.runtime.atn.LexerAction;
8 
9 import antlr.v4.runtime.InterfaceLexer;
10 import antlr.v4.runtime.atn.LexerActionType;
11 
12 // Interface LexerAction
13 /**
14  * Represents a single action which can be executed following the successful
15  * match of a lexer rule. Lexer actions are used for both embedded action syntax
16  * and ANTLR 4's new lexer command syntax.
17  */
18 interface LexerAction
19 {
20 
21     /**
22      * Gets the serialization type of the lexer action.
23      *
24      *  @return The serialization type of the lexer action.
25      */
26     public LexerActionType getActionType();
27 
28     /**
29      * Gets whether the lexer action is position-dependent. Position-dependent
30      * actions may have different semantics depending on the {@link CharStream}
31      * index at the time the action is executed.
32      *
33      * <p>Many lexer commands, including {@code type}, {@code skip}, and
34      * {@code more}, do not check the input index during their execution.
35      * Actions like this are position-independent, and may be stored more
36      * efficiently as part of the {@link LexerATNConfig#lexerActionExecutor}.</p>
37      *
38      *  @return {@code true} if the lexer action semantics can be affected by the
39      * position of the input {@link CharStream} at the time it is executed;
40      * otherwise, {@code false}.
41      */
42     public bool isPositionDependent();
43 
44     /**
45      * Execute the lexer action in the context of the specified {@link Lexer}.
46      *
47      * <p>For position-dependent actions, the input stream must already be
48      * positioned correctly prior to calling this method.</p>
49      *
50      *  @param lexer The lexer instance.
51      */
52     public void execute(InterfaceLexer lexer);
53 
54     /**
55      * @uml
56      * @nothrow
57      */
58     public size_t toHash() nothrow;
59 
60 }