HANDBOOK
/
GENTLE PRIMER
The
Gentle Compiler Construction System
generates efficient compilers from high-level specifications. The
Gentle Compiler Description Language
provides a simple and uniform notation for such specifications.
At a Glance
A Parser for Expressions
A Calculator
Abstract Syntax
Translating Concrete Syntax into Abstract Syntax
Traversal
Transformation
Code Generation
Elements of Specifications
Describing Data
Terms
Type Definitions
Using Terms in Expressions and Patterns
Numbers and Strings
Describing Computations
Invocations and Rules
Failure
Expressions and Patterns
Rule Bodies
Variables
Evaluation Strategy
Shallow Backtracking
Predicate Declarations
Conditions and Actions
Describing Syntax
Syntax Definitions
Nonterm Predicates
Token Predicates
Attributes
Actions in Grammar Rules
Rule Selection
Abstract Syntax
Source Coordinates
Using Types and Predicates Written in C
External Types
External Predicates
Handling Global Information
Handling Mutable Information
Control Structures
The Alternative Statement
Dataflow
The Predicate
where
Disjunctions
The Conditional Statement
Using Alternative and Conditional Statements
Smart Traversal
Default Rule
Broadcasted Parameter
Threaded Parameter
Optimal Rule Selection
Code Generation for Expressions
A Stack Computer
Unparsing
A Computer with an Accumulator
A Combined Stack and Accumulator Computer
Nondeterministic Unparsing
A Code-Generator Specification
Cost-Driven Rule Selection
Using Output Parameters
The Two Processing Phases
Well-formed Rules
Special Patterns and Expressions
Joker
Named Patterns
Type Prefixes
A Summary of Predefined Predicates
The Predicates
eq
,
ne
,
lt
,
le
,
ge
,
gt
The Predicate
print
The Predicate
where
The Predicate
@
Organizing Larger Projects
The Module Name
The Use Clause
The Export Clause
The Root Module