Transcript SableCC

SableCC
• SableCC is developed by professors and
graduate students at McGill University and
is open source (licensed under the Apache
License, Version 2.0)
SableCC
• SableCC is a compiler generator that
generates compilers in Java, but can also
output code in C, C++, C#, and Python.
• SableCC is written in Java itself and is
cross-platform.
• SableCC has its own format for input
grammars.
SableCC
1.
2.
3.
4.
5.
Target language specification
Generation of scanner and parser
code in java or desired output language
Code for actions to be executed
by scanner and parser, possibly
modifying their behavior through
inheritance.
Main program that makes calls to
generated compiler classes
Compilation of complete compiler
SableCC
• Compilers generated by SableCC build an
abstract syntax tree while parsing the
code.
• The AST generated by the compiler
matches the concrete syntax tree of the
code, but can be modified by classes
inheriting from the generated parser class.
SableCC
• Dynamic Linking and cross-platform
execution leads to slow execution.
• SableCC seeks to make Java programs run
faster and to gain insight into its execution.
SableCC
• Claim that typical lexer generators limit the
usable alphabet to the ASCII character set.
SableCC supports Unicode.
• SableCC allows for a larger alphabet by
defining symbols as intervals of charaters
and creating an alphabet that just fits the
needs.
• LALR(1) based parser
• Automatic AST generation
SableCC
• Future additions:
– Lookahead for FSA
– Improvement to lexer, parser, and debugging
– Flexible code generation
– Automated error recovery