summaryrefslogtreecommitdiffhomepage
path: root/tools/dfagen/dfagen/parser.g
diff options
context:
space:
mode:
authorNicolas Schodet2009-05-08 23:07:25 +0200
committerNicolas Schodet2009-05-08 23:07:25 +0200
commitb566e4bcd0c7cb3c90ad941b37db223134090ded (patch)
tree7d3f24a25860e17e7fa9cd017ad2d8bd8c0bd227 /tools/dfagen/dfagen/parser.g
parent6b3d5061623a35c96e66e25fc14af6a9323f81b0 (diff)
* tools/dfagen:
- added state attributes. - added support for more than one initial state. - added table of transitions with only one default branch. - added state and event template parameter. - added --output-dir. - make template directory relative to config file. - more options checking. - added transition attributes and callback definition. - conserve input file order in output. - added --dump and more option checking. - fixed missing newline.
Diffstat (limited to 'tools/dfagen/dfagen/parser.g')
-rw-r--r--tools/dfagen/dfagen/parser.g16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/dfagen/dfagen/parser.g b/tools/dfagen/dfagen/parser.g
index 62f9f4d1..e510ed22 100644
--- a/tools/dfagen/dfagen/parser.g
+++ b/tools/dfagen/dfagen/parser.g
@@ -10,6 +10,7 @@ parser AutomatonParser:
token EVENT: "\w([\w ]*\w)?"
token QUALIFIER: "\w([\w ]*\w)?"
token ATITLE: ".*?\n"
+ token ATTR: "\w([\w =]*\w)?"
rule automaton: ATITLE {{ a = Automaton (ATITLE.strip ()) }}
( comments {{ a.comments = comments }}
@@ -23,13 +24,19 @@ parser AutomatonParser:
( transdef<<a>>
) *
EOF {{ return a }}
-
- rule statedef: " " STATE {{ s = State (STATE) }}
+
+ rule statedef: {{ initial = False }}
+ " " ( "\*" {{ initial = True }}
+ ) ?
+ STATE {{ s = State (STATE, initial = initial) }}
+ ( "\s*\[\s*"
+ ATTR {{ s.attributes = ATTR }}
+ "\s*\]" ) ?
"\n"
( comments {{ s.comments = comments }}
) ?
{{ return s }}
-
+
rule eventdef: " " EVENT {{ e = Event (EVENT) }}
"\n"
( comments {{ e.comments = comments }}
@@ -52,6 +59,9 @@ parser AutomatonParser:
"\s*->\s*"
( STATE {{ t.to = a.states[STATE] }}
| "\\." )
+ ( "\s*\[\s*"
+ ATTR {{ t.attributes = ATTR }}
+ "\s*\]" ) ?
( comments {{ t.comments = comments }}
) ?
{{ return t }}