在令牌块中定义令牌与将令牌定义为词法索引之间有什么区别?
The lexer tokens are the tokens that antlr generates through parsing a certain combination of characters, for example:
fragment
F_W : (' '|'\t'|'\r'|'\n'|'\f')*
;
However, the tokens in the token block are the visual tokens that users create for the benefits of parsing; they don't have a direct mappings to a set of character series. For example,
tokens { BLOCK; }
gives you a visual token BLOCK that you can put ahead or on top of your block rule to mark the subsequest session is a block rule like this:
block:
'{' expression* '}' ->
BLOCK^ expression*
;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.