SYNOPSIS
Compile it with
eyapp -b '' Cplusplus2.eyp
Run it with:
./Cplusplus2.pm -t
try with inputs:
int (x) = 2;
int (x) + 2;
the result will be the generated abstract sytax tree
C++ Ambiguities
This grammar models a problematic part of the C++ grammar—the ambiguity between certain declarations and statements. For example,
int (x) = y+z;
parses as either an expr or a stmt.
Eyapp detects this as a reduce/reduce conflict:
State 17 contains 1 reduce/reduce conflict
State 17:
expr -> ID . (Rule 5)
declarator -> ID . (Rule 11)
')' [reduce using rule 11 (declarator)]
$default reduce using rule 5 (expr)
The C++ rule is: take it as a declaration if it looks as a declaration, otherwise is an expression.
This Eyapp parser solves the problem by dynamically changing the parser (hacking).
SEE ALSO
File
Cplusplus.eypinexamples/debuggintuthttp://www.gnu.org/software/bison/manual/html_mono/bison.html#GLR-Parsers
http://en.wikipedia.org/wiki/Significantly_Prettier_and_Easier_C%2B%2B_Syntax
http://www.csse.monash.edu.au/~damian/papers/PS/ModestProposal.ps
Edward Willink's "Meta-Compilation for C++" PhD thesis at http://www.computing.surrey.ac.uk/Research/CSRG/fog/FogThesis.pdf
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 121:
Non-ASCII character seen before =encoding in 'grammar—the'. Assuming UTF-8