summaryrefslogtreecommitdiff
path: root/tools/dfagen/dfagen/parser.g
diff options
context:
space:
mode:
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 }}