Просмотр исходного кода

Merge branch 'master' of kompiler.org:trs

Taddeus Kroes 14 лет назад
Родитель
Сommit
430b1f498d
2 измененных файлов с 9 добавлено и 3 удалено
  1. 1 1
      external/pybison
  2. 8 2
      src/parser.py

+ 1 - 1
external/pybison

@@ -1 +1 @@
-Subproject commit 805ca9d3acb5053906157b66604a1ac5054c2df3
+Subproject commit b4fd7ccf01d7030c3d6207c1ce2ff6bdbb8cad55

+ 8 - 2
src/parser.py

@@ -50,7 +50,7 @@ class Parser(BisonParser):
     # ----------------------------------------------------------------
     # ----------------------------------------------------------------
     # TODO: add a runtime check to verify that this token list match the list
     # TODO: add a runtime check to verify that this token list match the list
     # of tokens of the lex script.
     # of tokens of the lex script.
-    tokens = ['NUMBER', 'IDENTIFIER',
+    tokens = ['NUMBER', 'IDENTIFIER', 'POSSIBILITIES',
               'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'POW',
               'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'POW',
               'LPAREN', 'RPAREN', 'COMMA', 'HINT', 'REWRITE',
               'LPAREN', 'RPAREN', 'COMMA', 'HINT', 'REWRITE',
               'NEWLINE', 'QUIT', 'RAISE', 'GRAPH']
               'NEWLINE', 'QUIT', 'RAISE', 'GRAPH']
@@ -203,6 +203,7 @@ class Parser(BisonParser):
              | exp NEWLINE
              | exp NEWLINE
              | debug NEWLINE
              | debug NEWLINE
              | HINT NEWLINE
              | HINT NEWLINE
+             | POSSIBILITIES NEWLINE
              | REWRITE NEWLINE
              | REWRITE NEWLINE
              | RAISE NEWLINE
              | RAISE NEWLINE
         """
         """
@@ -214,10 +215,14 @@ class Parser(BisonParser):
             return
             return
 
 
         if option == 4:
         if option == 4:
+            print '\n'.join(map(str, self.last_possibilities))
+            return
+
+        if option == 5:
             suggestion = pick_suggestion(self.last_possibilities)
             suggestion = pick_suggestion(self.last_possibilities)
             return apply_suggestion(suggestion)
             return apply_suggestion(suggestion)
 
 
-        if option == 5:
+        if option == 6:
             raise RuntimeError('on_line: exception raised')
             raise RuntimeError('on_line: exception raised')
 
 
     def on_debug(self, target, option, names, values):
     def on_debug(self, target, option, names, values):
@@ -345,6 +350,7 @@ class Parser(BisonParser):
     "^"       { returntoken(POW); }
     "^"       { returntoken(POW); }
     "/"       { returntoken(DIVIDE); }
     "/"       { returntoken(DIVIDE); }
     ","       { returntoken(COMMA); }
     ","       { returntoken(COMMA); }
+    "??"      { returntoken(POSSIBILITIES); }
     "?"       { returntoken(HINT); }
     "?"       { returntoken(HINT); }
     "@"       { returntoken(REWRITE); }
     "@"       { returntoken(REWRITE); }
     "quit"    { yyterminate(); returntoken(QUIT); }
     "quit"    { yyterminate(); returntoken(QUIT); }