Skip to content

antlr 使用

Posted on:August 16, 2023 at 12:59 PM


ANTLR 是一个lex/parser 工具,类似与c的bison/yacc


Token names always start with a capital letter and so do lexer rules as defined by Java’s Character.isUpperCase method. Parser rule names always start with a lowercase letter (those that fail Character.isUpperCase). The initial character can be followed by uppercase and lowercase letters, digits, and underscores. Here are some sample names:

ID, LPAREN, RIGHT_CURLY // token names/lexer rules
expr, simpleDeclarator, d2, header_file // parser rule names

大写字母开头的都是token name 或者lexer rurles name 消息的都是parser rule name