COP 5021 Lecture -*- Outline -*- * Overview of JastAdd ** basic tool usage ------------------------------------------ TYPICAL USAGE OF THE TOOLS ant gen mkdir AST jastadd Lang.ast ----------> AST/.java jflex Lang.flex --------> AST/LangScanner.java beaver Lang.parser ---------> AST/LangParser.java ------------------------------------------ In the AST directory, there is a nonterminal class for each nonterminal in the abstract syntax Note that jflex and beaver could be replaced by other lexer and parser generator tools. The ant task does all of this in a coordinated way. ** what happens at runtime ------------------------------------------ AT RUNTIME "y := 5; ..." BufferedReader br = | new BufferedReader(new FileReader(fname)); | (chars) v LangScanner | LangScanner scanner = | (tokens) new LangScanner(br); v LangParser | LangParser parser = | (ASTs) new LangParser(); | (Program)parser.parse(scanner); v Program AST ------------------------------------------ The code to the right shows how the pipeline is set up.