1*37748cd8SNickeau<?php 2*37748cd8SNickeau 3*37748cd8SNickeaudeclare(strict_types=1); 4*37748cd8SNickeau 5*37748cd8SNickeaunamespace Antlr\Antlr4\Runtime; 6*37748cd8SNickeau 7*37748cd8SNickeau/** 8*37748cd8SNickeau * This interface provides information about the vocabulary used by a 9*37748cd8SNickeau * recognizer. 10*37748cd8SNickeau * 11*37748cd8SNickeau * @see Recognizer::getVocabulary() 12*37748cd8SNickeau */ 13*37748cd8SNickeauinterface Vocabulary 14*37748cd8SNickeau{ 15*37748cd8SNickeau /** 16*37748cd8SNickeau * Returns the highest token type value. It can be used to iterate from zero 17*37748cd8SNickeau * to that number, inclusively, thus querying all stored entries. 18*37748cd8SNickeau * 19*37748cd8SNickeau * @return int The highest token type value. 20*37748cd8SNickeau */ 21*37748cd8SNickeau public function getMaxTokenType() : int; 22*37748cd8SNickeau 23*37748cd8SNickeau /** 24*37748cd8SNickeau * Gets the string literal associated with a token type. The string returned 25*37748cd8SNickeau * by this method, when not `null`, can be used unaltered in a parser grammar 26*37748cd8SNickeau * to represent this token type. 27*37748cd8SNickeau * 28*37748cd8SNickeau * The following table shows examples of lexer rules and the literal names 29*37748cd8SNickeau * assigned to the corresponding token types. 30*37748cd8SNickeau * 31*37748cd8SNickeau * Rule | Literal Name | Java String Literal 32*37748cd8SNickeau * -----------------|--------------|--------------------- 33*37748cd8SNickeau * `THIS : 'this';` | `'this'` | `"'this'"` 34*37748cd8SNickeau * `SQUOTE : '\'';` | `'\''` | `"'\\''"` 35*37748cd8SNickeau * `ID : [A-Z]+;` | n/a | `null` 36*37748cd8SNickeau * 37*37748cd8SNickeau * @param int $tokenType The token type. 38*37748cd8SNickeau * 39*37748cd8SNickeau * @return string The string literal associated with the specified token type, 40*37748cd8SNickeau * or `null` if no string literal is associated with the type. 41*37748cd8SNickeau */ 42*37748cd8SNickeau public function getLiteralName(int $tokenType) : ?string; 43*37748cd8SNickeau 44*37748cd8SNickeau /** 45*37748cd8SNickeau * Gets the symbolic name associated with a token type. The string returned 46*37748cd8SNickeau * by this method, when not `null`, can be used unaltered in a parser grammar 47*37748cd8SNickeau * to represent this token type. 48*37748cd8SNickeau * 49*37748cd8SNickeau * This method supports token types defined by any of the following methods: 50*37748cd8SNickeau * 51*37748cd8SNickeau * - Tokens created by lexer rules. 52*37748cd8SNickeau * - Tokens defined in a `tokens{}` block in a lexer or parser grammar. 53*37748cd8SNickeau * - The implicitly defined `EOF` token, which has the token type {@see Token::EOF()}. 54*37748cd8SNickeau * 55*37748cd8SNickeau * The following table shows examples of lexer rules and the literal names 56*37748cd8SNickeau * assigned to the corresponding token types. 57*37748cd8SNickeau * 58*37748cd8SNickeau * Rule | Symbolic Name 59*37748cd8SNickeau * -----------------|-------------- 60*37748cd8SNickeau * `THIS : 'this';` | `THIS` 61*37748cd8SNickeau * `SQUOTE : '\'';` | `SQUOTE` 62*37748cd8SNickeau * `ID : [A-Z]+;` | `ID` 63*37748cd8SNickeau * 64*37748cd8SNickeau * @param int $tokenType The token type. 65*37748cd8SNickeau * 66*37748cd8SNickeau * @return string The symbolic name associated with the specified token type, 67*37748cd8SNickeau * or `null` if no symbolic name is associated with the type. 68*37748cd8SNickeau */ 69*37748cd8SNickeau public function getSymbolicName(int $tokenType) : ?string; 70*37748cd8SNickeau 71*37748cd8SNickeau /** 72*37748cd8SNickeau * Gets the display name of a token type. 73*37748cd8SNickeau * 74*37748cd8SNickeau * ANTLR provides a default implementation of this method, but applications 75*37748cd8SNickeau * are free to override the behavior in any manner which makes sense 76*37748cd8SNickeau * for the application. The default implementation returns the first result 77*37748cd8SNickeau * from the following list which produces a non-null result. 78*37748cd8SNickeau * 79*37748cd8SNickeau * @param int $tokenType The token type. 80*37748cd8SNickeau * 81*37748cd8SNickeau * @return string The display name of the token type, for use in 82*37748cd8SNickeau * error reporting or other user-visible messages 83*37748cd8SNickeau * which reference specific token types. 84*37748cd8SNickeau */ 85*37748cd8SNickeau public function getDisplayName(int $tokenType) : string; 86*37748cd8SNickeau} 87