]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/lablgtk/lablgtk_20000829-0.1.0/applications/radtest/load_parser.mly
Initial revision
[helm.git] / helm / DEVEL / lablgtk / lablgtk_20000829-0.1.0 / applications / radtest / load_parser.mly
diff --git a/helm/DEVEL/lablgtk/lablgtk_20000829-0.1.0/applications/radtest/load_parser.mly b/helm/DEVEL/lablgtk/lablgtk_20000829-0.1.0/applications/radtest/load_parser.mly
new file mode 100644 (file)
index 0000000..09c7b7b
--- /dev/null
@@ -0,0 +1,56 @@
+%{
+open Utils
+%}
+
+%token EOF NAME EQUAL SUP WINDOW_START WINDOW_END
+%token <string> WIDGET_START WIDGET_END IDENT
+
+%type <string> window_start
+%type <string * string> property widget_start
+%type <(string * string) list> property_list
+%type <Utils.yywidget_tree> widget window
+%type <Utils.yywidget_tree list> children window_list project
+
+%start project
+%start window
+%start widget
+
+%%
+
+project : window_list EOF        { List.rev $1 }
+
+window_list :                    { [] }
+            | window_list window { $2 :: $1 }
+; 
+
+window : window_start property_list children WINDOW_END 
+  { 
+    Node (("window", $1, List.rev $2), $3)
+  } 
+;
+
+window_start : WINDOW_START NAME EQUAL IDENT SUP   { $4 }
+;
+
+children  :                  { [] }
+         | children widget   { $2 :: $1 }
+;
+
+widget : widget_start property_list children WIDGET_END
+  { 
+    let classe, name = $1 in
+    if classe <> $4 then raise Parsing.Parse_error;
+    Node ((classe, name, List.rev $2), $3)
+  } 
+;
+
+widget_start  : WIDGET_START NAME EQUAL IDENT SUP   { $1, $4 }
+;
+
+property_list :                         { [] }
+              | property_list property  { $2 :: $1 }
+;
+
+property      : IDENT EQUAL IDENT       { $1, $3 }
+;
+