Anonymous avatar Anonymous committed d25647f

Fix a bug, identify a token collision, fix an example, all pass.

Comments (0)

Files changed (6)

doc/ALPACA.markdown

 
     | neighbourhood Moore
     |   (< > ^ v ^> ^< v> v<);
-    | neighbourhood vonNeumann
+    | neighbourhood VonNeumann
     |   (^ v < >);
     | state Space
     |   to Thing when 1 in Moore Thing;
 by some other description, however, this spec does not define a standard
 way in which that could happen.
 
+`arrow-chain` and `identifier` tokens overlap; tokens beginning with a
+series of `v`s (lower-case letter "vee"s) will be interpreted as an `arrow-chain`.
+Thus, the text `vonNeumann` will be scanned as the arrow-chain `v` followed
+by the identifier `onNeumann`.  Until such time as this is addressed, avoid
+giving states, classes, and neighbourhoods names which begin with a lowercase
+`v`.  (Convention says to start these identifiers with uppercase letters
+anyhow.)
+
 Differences between ALPACA 1.0 and Previous Versions
 ----------------------------------------------------
 

eg/nbhd1.alp

-neighbourhood Moore
-  (< > ^ v ^> ^< v> v<);
-neighbourhood vonNeumann
-  (^ v < >);
-state Space
-  to Thing when 1 in Moore Thing;
-state Thing
-  to Space when 3 in (^ v < >) Space.

eg/neighbourhood2.alp

+neighbourhood Moore
+  (< > ^ v ^> ^< v> v<);
+neighbourhood Foo
+  (^ v < >);
+state Space
+  to Thing when 1 in Moore Thing;
+state Thing
+  to Space when 3 Space.

src/alpaca/ast.py

         else:
             self.children = []
         assert isinstance(self.children, list)
-
-    def add_child(self, item):
-        self.children.append(item)
+        for child in self.children:
+            assert isinstance(child, AST), \
+              "child %r of %r is not an AST node" % (child, self)        
 
     def __repr__(self):
         if self.value is None:
         if not self.children:
             return 'AST(%r,value=%r)' % (self.type, self.value)
         return 'AST(%r,%r,value=%r)' % (self.type, self.children, self.value)
-
-    def check(self):
-        for child in self.children:
-            assert isinstance(child, AST), \
-              "child %r of %r is not an AST node" % (child, self)
-            child.check()

src/alpaca/main.py

     text = file.read()
     file.close()
     ast = Parser(text).alpaca()
-    ast.check()
     if options.parse_only:
         sys.exit(0)
     if options.show_ast:

src/alpaca/parser.py

             nb = NBHD_MOORE
             if self.scanner.consume('in'):
                 if self.scanner.on_type('identifier'):
-                    nb = self.scanner.consume('identifier')
+                    nb = AST('NbhdRef',
+                             value=self.scanner.consume_type('identifier'))
                 else:
                     nb = self.neighbourhood()
             if self.scanner.consume('is'):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.