- 论坛徽章:
- 0
|
*******************************
CHAPTER 15
Grammar Reference
跳到 最后一章 类似复习
*******************************
作者可能 编译器水平非常高,但是 写作水平 实在 无法恭维。
感觉这本书,重点不突出,很像流水账。
This chapter is a reference and
summarizes grammar syntax and the key semantics of ANTLR grammars.
其实这章应该放在 前面,而且再细致些。
******************************
15.1 Grammar Lexicon
又 词法
*****************************
我为什么说个 又 ?
The lexicon of ANTLR is familiar to most programmers because it follows the
syntax of C and its derivatives with some extensions for grammatical
descriptions.
Comments
There are single-line, multiline, and Javadoc-style comments.
Identifiers
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()).
Literals
All literal strings that are one or more characters in length are
enclosed in single quotes such as ';', 'if', '>=', and '\''
Actions
Actions are code blocks written in the target language.
Keywords
Here’s a list of the reserved words in ANTLR grammars: import, fragment, lexer,
parser, grammar, returns, locals, throws, catch, finally, mode, options, tokens.
|
|