Download From stack removing in stack-based languages to BibTEX++

Transcript
CHAPTER 3. BIBTEX++
Figure 3.2: BiSTrO Architecture
The Tree translator : first, it makes several passes in the bst AST in
order to obtain information about bst functions, elements on the stack
and possibility to remove the stack. Then, it converts the bst AST into
a JAVA AST.
The JAVA optimizer : it modifies the JAVA tree in order to optimize the
legibility of the generated code. It uses several independent optimizations to allow the user to choose which optimizations he wants to use
at the time of the execution.
The Pretty Printer : it transforms the optimized (or not) JAVA tree into
a real JAVA file. It also indents this code to increase its legibility.
3.2.2
The Parser / Lexer
There are only few compiler compilers which allow to create Abstract
Syntax Tree (AST). Most of them, execute an action code as soon as the
generated parser discovers an element of the grammar (like YACC [11] and
JAVA CUP [9] for example). So it’s difficult to generate multiple pass compilers with these compiler compilers without rebuilding an AST. For JAVA,
the most known which permits to create AST is ANTLR2.xx [15], a JAVA
implementation of PCCTS [14].
Nevertheless, ANTLR lexer does not support 16 bits unicode character
input. It is why we chose here the SableCC framework [7]. SableCC sits in
the middle between front-end compiler compilers (a lexer plus a parser) and
end-to-end compiler compilers which provide complete compilers. We chose
it because it has lots of useful features like :
18