From b566e4bcd0c7cb3c90ad941b37db223134090ded Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Fri, 8 May 2009 23:07:25 +0200 Subject: * 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. --- tools/dfagen/dfagen/parser.g | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'tools/dfagen/dfagen/parser.g') 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<> ) * 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 }} -- cgit v1.2.3