Generating AST using javacc and jjtree



Hi all,
I am using javacc and jjtree to generate an AST for a C++ input file. I
have got the file parsing fine, and the generated tree is printed
below. Is there any way to extract the information about the nodes from
the tree (e.g. instead of just "logical_and_expression", see the actual
information / text about the node) ?

The AST shown below is for the program shown here (hello world). That's
why I'm not sure what or how its managed to generate the AST below with
all inclusive_or_expressions etc etc.

Thanks a lot!

Code:
int main()
{
print("Hello world");
}

Parser output:
C++ Parser Version 0.1: Reading from file Test.cpp . . .
translation_unit
external_declaration
function_definition
declaration_specifiers
builtin_type_specifier
function_declarator
function_direct_declarator
qualified_id
func_decl_def
compound_statement
statement_list
statement
expression
assignment_expression
conditional_expression
logical_or_expression
logical_and_expression
inclusive_or_expression
exclusive_or_expression
and_expression
equality_expression
relational_expression
shift_expression
additive_expression
multiplicative_expression
pm_expression
cast_expression
unary_expression
postfix_expression
primary_expression
id_expression
expression_list
assignment_expression
conditional_expression
logical_or_expression
logical_and_expression
inclusive_or_expression
exclusive_or_expression
and_expression
equality_expression
relational_expression
shift_expression
additive_expression
multiplicative_expression
pm_expression
cast_expression
unary_expression
postfix_expression
primary_expression
C++ Parser Version 0.1: Program parsed successfully.

.



Relevant Pages

  • Generate AST for C++ input
    ... I am using javacc and jjtree to generate an AST for a C++ input file. ... have got the file parsing fine, and the generated tree is printed ... Parser output: ...
    (comp.compilers.tools.javacc)
  • Re: Creating scripting language with JavaCC
    ... I want to create a simple scripting language - something like VBScript ... How do I create an AST for this, ... with their own tree. ... identifier() identifier ...
    (comp.compilers.tools.javacc)
  • Re: [Q] How Is AST structured for entire program??
    ... An AST is usually abstract (throwing away unimportant details), ... a parse tree is also an AST (where the set of details thrown away ... A branch of tree is a tree. ... Bob Morgan's compiler construction book and then Steve Muchnik's if you ...
    (comp.compilers)
  • Re: RM and abstract syntax trees
    ... Abstract Syntax Tree (AST), concluding that RM is poorly suited. ... of the parse tree, not the AST. ...
    (comp.databases.theory)
  • Re: Formelparser
    ... >> Abstract Syntax Tree (AST) und Expression Parsing. ... Der Begriff Token ist leider auch im Compilerbau relativ überladen. ... >> wird nahezu immer Parser gennant. ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)