1*37748cd8SNickeau<?php 2*37748cd8SNickeau 3*37748cd8SNickeaudeclare(strict_types=1); 4*37748cd8SNickeau 5*37748cd8SNickeaunamespace Antlr\Antlr4\Runtime\Atn\Actions; 6*37748cd8SNickeau 7*37748cd8SNickeauuse Antlr\Antlr4\Runtime\Comparison\Hashable; 8*37748cd8SNickeauuse Antlr\Antlr4\Runtime\Lexer; 9*37748cd8SNickeau 10*37748cd8SNickeau/** 11*37748cd8SNickeau * Represents a single action which can be executed following the successful 12*37748cd8SNickeau * match of a lexer rule. Lexer actions are used for both embedded action syntax 13*37748cd8SNickeau * and ANTLR 4's new lexer command syntax. 14*37748cd8SNickeau * 15*37748cd8SNickeau * @author Sam Harwell 16*37748cd8SNickeau */ 17*37748cd8SNickeauinterface LexerAction extends Hashable 18*37748cd8SNickeau{ 19*37748cd8SNickeau /** 20*37748cd8SNickeau * Gets the serialization type of the lexer action. 21*37748cd8SNickeau * 22*37748cd8SNickeau * @return int The serialization type of the lexer action. 23*37748cd8SNickeau */ 24*37748cd8SNickeau public function getActionType() : int; 25*37748cd8SNickeau 26*37748cd8SNickeau /** 27*37748cd8SNickeau * Gets whether the lexer action is position-dependent. Position-dependent 28*37748cd8SNickeau * actions may have different semantics depending on the {@see CharStream} 29*37748cd8SNickeau * index at the time the action is executed. 30*37748cd8SNickeau * 31*37748cd8SNickeau * Many lexer commands, including `type`, `skip`, and `more`, do not check 32*37748cd8SNickeau * the input index during their execution. Actions like this are 33*37748cd8SNickeau * position-independent, and may be stored more efficiently as part of the 34*37748cd8SNickeau * {@see LexerATNConfig::lexerActionExecutor()}. 35*37748cd8SNickeau * 36*37748cd8SNickeau * @return bool `true` if the lexer action semantics can be affected by the 37*37748cd8SNickeau * position of the input {@see CharStream} at the time it is 38*37748cd8SNickeau * executed; otherwise, `false`. 39*37748cd8SNickeau */ 40*37748cd8SNickeau public function isPositionDependent() : bool; 41*37748cd8SNickeau 42*37748cd8SNickeau /** 43*37748cd8SNickeau * Execute the lexer action in the context of the specified {@see Lexer}. 44*37748cd8SNickeau * 45*37748cd8SNickeau * For position-dependent actions, the input stream must already be 46*37748cd8SNickeau * positioned correctly prior to calling this method. 47*37748cd8SNickeau * 48*37748cd8SNickeau * @param Lexer $lexer The lexer instance. 49*37748cd8SNickeau */ 50*37748cd8SNickeau public function execute(Lexer $lexer) : void; 51*37748cd8SNickeau} 52