Commits

Anonymous committed ae50ea1

Begin to make error messaging conform.

  • Participants
  • Parent commits 5b12782

Comments (0)

Files changed (2)

File README.markdown

 
     | a := { b := 6 }
     | print a.c
-    ? Attempt to access an undefined variable
+    ? Attempt to access undefined variable c
 
     | a := { b := 6 }
     | a.c := 12
-    ? Attempt to assign an undefined variable
+    ? Attempt to assign undefined variable c
 
 Stores and integers are the only two data types in Xoomonk.  However, there
 are some special forms of the print statement, demonstrated here, which

File src/xoomonk.py

         new.dict = self.dict.copy()
         return new
 
-    def get(self, name, default):
-        if name not in self.variables:
-            return default
-        return self.dict[name]
-
     def __getitem__(self, name):
         if name not in self.variables:
             raise ValueError("Attempt to access undefined variable %s" % name)
                 store_to_use = store_to_use[name]
                 i += 1
         name = ast.children[-1].value
-        return store_to_use.get(name, 0)
+        return store_to_use[name]
     elif type == 'IntLit':
         return ast.value
     elif type == 'CopyOf':
     ast = p.program()
     if options.show_ast:
         print repr(ast)
-    result = eval_xoomonk(ast, {})
+    try:
+        result = eval_xoomonk(ast, {})
+    except ValueError as e:
+        print >>sys.stderr, str(e)
+        sys.exit(1)
     sys.exit(0)