branches/work/kdevelop-pg/src

Jakob Petsovits jpetso at gmx.at
Tue Jul 18 23:08:37 UTC 2006


SVN commit 563962 by jpetso:

jpetso proudly presents...
Rule Arguments for kdevelop-pg!

They make it possible to tune the abstract syntax tree (AST)
in order to make it clearer and more usable for later on.

If your grammar doesn't use rule arguments, you get exactly
the same output parser than before this patch.


Syntax for rule "calls" (example):

   singlearg_rule[arg] doublearg_rule[arg1, arg2]
-> rule_argument_calls ;;


Syntax for rule parameter declarations (in pseudo-rule form):

   items
-> rulename [
     declaration*
] ;;

   ("argument"|0) storage_type common_variable_type ("#"|0) name: type;
 | ("argument"|0) storage_type "token" ("#"|0) name;
-> declaration ;;

   ("member" | "temporary")
-> storage_type ;;

   ("node" | "variable")
-> common_variable_type ;;


Example for a declaration:

   0 [: temp_counter = 0; :]
   (item [: temp_counter++; :] )*
     [: (*yynode)->type = class_declaration_ast::item_list; :]
   -- this was the example rule body, now for the parameter declaration:
-> class_declaration [
     argument member node mods: optional_modifiers;
     member variable type: class_declaration_ast::type_enum;
     temporary variable temp_counter: int;
     temporary token #blah;  -- a sequence, like in normal annotations
] ;;


I'll port the kdevelop-pg/examples/ grammars tomorrow.
Questions, suggestions, complaints and praises go to
jpetso at gmx.at or kdevelop-devel at kdevelop.org .

CCMAIL: kdevelop-devel at kdevelop.org


 M  +5 -3      kdev-pg-ast-gen.cpp  
 M  +2 -1      kdev-pg-ast-gen.h  
 M  +41 -19    kdev-pg-ast.h  
 M  +29 -0     kdev-pg-checker.cpp  
 M  +1 -0      kdev-pg-checker.h  
 M  +6 -3      kdev-pg-clone-tree.cpp  
 M  +188 -59   kdev-pg-code-gen.cpp  
 M  +16 -2     kdev-pg-code-gen.h  
 M  +11 -12    kdev-pg-default-visitor-gen.cpp  
 M  +3 -2      kdev-pg-default-visitor-gen.h  
 M  +8 -0      kdev-pg-default-visitor.cpp  
 M  +2 -0      kdev-pg-default-visitor.h  
 M  +92 -16    kdev-pg-lexer.ll  
 M  +72 -15    kdev-pg-parser.yy  
 M  +5 -3      kdev-pg-pretty-printer.cpp  
 M  +3 -1      kdev-pg-visitor.cpp  
 M  +2 -0      kdev-pg-visitor.h  
 M  +48 -11    kdev-pg.cpp  
 M  +15 -5     kdev-pg.h  






More information about the KDevelop-devel mailing list