Revision 563962

Go back to digest for 23rd July 2006

Features in Development Tools

Jakob Petsovits committed changes in /branches/work/kdevelop-pg/src:

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
or .

File Changes

Modified 19 files
  • /branches/work/kdevelop-pg/src
  •   /kdev-pg-ast-gen.cpp
  •   /kdev-pg-ast-gen.h
  •   /kdev-pg-ast.h
  •   /kdev-pg-checker.cpp
  •   /kdev-pg-checker.h
  •   /kdev-pg-clone-tree.cpp
  •   /kdev-pg-code-gen.cpp
  •   /kdev-pg-code-gen.h
  •   /kdev-pg-default-visitor-gen.cpp
  •   /kdev-pg-default-visitor-gen.h
  •   /kdev-pg-default-visitor.cpp
  •   /kdev-pg-default-visitor.h
  •   /kdev-pg-lexer.ll
  •   /kdev-pg-parser.yy
  •   /kdev-pg-pretty-printer.cpp
  •   /kdev-pg-visitor.cpp
  •   /kdev-pg-visitor.h
  •   /kdev-pg.cpp
  •   /kdev-pg.h
19 files changed in total