Class LexerTypeAction

  • All Implemented Interfaces:
    LexerAction

    public class LexerTypeAction
    extends java.lang.Object
    implements LexerAction
    Implements the type lexer action by calling Lexer.setType(int) with the assigned type.
    Since:
    4.2
    Author:
    Sam Harwell
    • Constructor Summary

      Constructors 
      Constructor Description
      LexerTypeAction​(int type)
      Constructs a new type action with the specified token type value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      void execute​(Lexer lexer)
      Execute the lexer action in the context of the specified Lexer.
      LexerActionType getActionType()
      Gets the serialization type of the lexer action.
      int getType()
      Gets the type to assign to a token created by the lexer.
      int hashCode()  
      boolean isPositionDependent()
      Gets whether the lexer action is position-dependent.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • LexerTypeAction

        public LexerTypeAction​(int type)
        Constructs a new type action with the specified token type value.
        Parameters:
        type - The type to assign to the token using Lexer.setType(int).
    • Method Detail

      • getType

        public int getType()
        Gets the type to assign to a token created by the lexer.
        Returns:
        The type to assign to a token created by the lexer.
      • isPositionDependent

        public boolean isPositionDependent()
        Gets whether the lexer action is position-dependent. Position-dependent actions may have different semantics depending on the CharStream index at the time the action is executed.

        Many lexer commands, including type, skip, and more, do not check the input index during their execution. Actions like this are position-independent, and may be stored more efficiently as part of the LexerATNConfig.lexerActionExecutor.

        Specified by:
        isPositionDependent in interface LexerAction
        Returns:
        This method returns false.
      • execute

        public void execute​(Lexer lexer)
        Execute the lexer action in the context of the specified Lexer.

        For position-dependent actions, the input stream must already be positioned correctly prior to calling this method.

        This action is implemented by calling Lexer.setType(int) with the value provided by getType().

        Specified by:
        execute in interface LexerAction
        Parameters:
        lexer - The lexer instance.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object