gl5_progのメモ

自分のためのメモとかまとめとか

ANTLR3メモ

メモ

用語

用語 説明
左括りだし( Left factoring ) Left factoring - Wikipedia, the free encyclopedia
統語的述語( Syntactic predicate ) Syntactic predicate - Wikipedia, the free encyclopedia
意味的述語?( Semantic Predicate ) This is Stuff: ANTLR - Semantic Predicates antlr - What is a 'semantic predicate' in ANTLR3? - Stack Overflow

疑問

  • lexerルールとparserルールの違いってなんだろう。
    • ここによると
      • paserルールはヘルパーlexerルールを参照しない
      • paserルールはparserルールを参照できる

リファレンス本目次

I Introducing ANTLR and Computer Language Translation

1 Getting Started with ANTLR

1.1 The Big Picture
1.2 An A-mazing Analogy
1.3 Installing ANTLR
1.4 Executing ANTLR and Invoking Recognizers
1.5 ANTLRWorks Grammar Development Environment

2 The Nature of Computer Languages

2.1 Generating Sentences with State Machines
2.2 The Requirements for Generating Complex Language
2.3 The Tree Structure of Sentences
2.4 Enforcing Sentence Tree Structure
2.5 Ambiguous Languages
2.6 Vocabulary Symbols Are Structured Too
2.7 Recognizing Computer Language Sentences

3 A Quick Tour for the Impatient

3.1 Recognizing Language Syntax
3.2 Using Syntax to Drive Action Execution
3.3 Evaluating Expressions via an AST Intermediate Form

II ANTLR Reference

4 ANTLR Grammars

4.1 Describing Languages with Formal Grammars
4.2 Overall ANTLR Grammar File Structure
4.3 Rules
4.4 Tokens Specification
4.5 Global Dynamic Attribute Scopes
4.6 Grammar Actions

5 ANTLR Grammar-Level Options

5.1 language Option
5.2 output Option
5.3 backtrack Option
5.4 memoize Option
5.5 tokenVocab Option
5.6 rewrite Option
5.7 superClass Option
5.8 filter Option
5.9 ASTLabelType Option
5.10 TokenLabelType Option
5.11 k Option

6 Attributes and Actions

6.1 Introducing Actions, Attributes, and Scopes
6.2 Grammar Actions
6.3 Token Attributes
6.4 Rule Attributes
6.5 Dynamic Attribute Scopes for Interrule Communication
6.6 References to Attributes within Actions

7 Tree Construction

7.1 Proper AST Structure
7.2 Implementing Abstract Syntax Trees
7.3 Default AST Construction
7.4 Constructing ASTs Using Operators
7.5 Constructing ASTs with Rewrite Rules

8 Tree Grammars

8.1 Moving from Parser Grammar to Tree Grammar
8.2 Building a Parser Grammar for the C- Language
8.3 Building a Tree Grammar for the C- Language

9 Generating Structured Text with Templates and Grammars

9.1 Why Templates Are Better Than Print Statements
9.2 Embedded Actions and Template Construction Rules
9.3 A Brief Introduction to StringTemplate
9.4 The ANTLR StringTemplate Interface
9.5 Rewriters vs. Generators
9.6 A Java Bytecode Generator Using a Tree Grammar and Templa
9.7 Rewriting the Token Buffer In-Place
9.8 Rewriting the Token Buffer with Tree Grammars
9.9 References to Template Expressions within Actions

10 Error Reporting and Recovery

10.1 A Parade of Errors
10.2 Enriching Error Messages during Debugging
10.3 Altering Recognizer Error Messages
10.4 Exiting the Recognizer upon First Error
10.5 Manually Specifying Exception Handlers
10.6 Errors in Lexers and Tree Parsers
10.7 Automatic Error Recovery Strategy

III Understanding Predicated-LL(*)Grammars

11 LL(*)Parsing

11.1 The Relationship between Grammars and Recognizers
11.2 Why You Need LL(*)
11.3 Toward LL(*) from LL(k)
11.4 LL(*) and Automatic Arbitrary Regular Lookahead
11.5 Ambiguities and Nondeterminisms

12 Using Semantic and Syntactic Predicates

12.1 Syntactic Ambiguities with Semantic Predicates
12.2 Resolving Ambiguities and Nondeterminisms

13 Semantic Predicates

13.1 Resolving Non-LL(*) Conflicts
13.2 Gated Semantic Predicates Switching Rules Dynamically
13.3 Validating Semantic Predicates
13.4 Limitations on Semantic Predicate Expressions

14 Syntactic Predicates

14.1 How ANTLR Implements Syntactic Predicates
14.2 Using ANTLRWorks to Understand Syntactic Predicates
14.3 Nested Backtracking
14.4 Auto-backtracking
14.5 Memoization
14.6 Grammar Hazards with Syntactic Predicates
14.7 Issues with Actions and Syntactic Predicates