2 files changed, 7 insertions(+), 2 deletions(-)
viff/sfdl/grammar.py           |    4 ++++
viff/test/sfdl/test_grammar.py |    5 +++--


# HG changeset patch
# User Martin Geisler <[EMAIL PROTECTED]>
# Date 1227518476 -3600
# Node ID 01b0e928dcbeea1b22329f4356840f3e49fefe30
# Parent  ad84b1d50412b49b96041aae42210635723d89bc
Store type declarations in global scope.

diff --git a/viff/sfdl/grammar.py b/viff/sfdl/grammar.py
--- a/viff/sfdl/grammar.py
+++ b/viff/sfdl/grammar.py
@@ -89,6 +89,7 @@
 
         int_type.setParseAction(self.parse_int_type)
         data_type.setParseAction(self.parse_data_type)
+        type_dec.setParseAction(self.parse_type_dec)
 
         self.expr = expr = Forward()
         self.qual_ident = qual_ident = ident \
@@ -172,3 +173,6 @@
             return attrdict(length=toks[1])
         else:
             return toks
+
+    def parse_type_dec(self, s, loc, toks):
+        self.global_scope[toks[1]] = toks[2]
diff --git a/viff/test/sfdl/test_grammar.py b/viff/test/sfdl/test_grammar.py
--- a/viff/test/sfdl/test_grammar.py
+++ b/viff/test/sfdl/test_grammar.py
@@ -156,8 +156,9 @@
     def test_type_dec(self):
         self.assertParse(self.grammar.type_dec, "type x = Boolean;",
                          ['type', 'x', 'Boolean'])
-        self.assertParse(self.grammar.type_dec, "type x = AnotherType[4];",
-                         ['type', 'x', attrdict(length=4)])
+        self.assertParse(self.grammar.type_dec, "type xs = AnotherType[4];",
+                         ['type', 'xs', attrdict(length=4)])
+        self.assertParse(self.grammar.const_expr, "xs.length", [4])
 
 
     def test_qual_ident(self):
_______________________________________________
viff-patches mailing list
viff-patches@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-patches-viff.dk

Reply via email to