Taddeus Kroes 14 лет назад
Родитель
Сommit
04ecc8b946
1 измененных файлов с 5 добавлено и 4 удалено
  1. 5 4
      src/parser.py

+ 5 - 4
src/parser.py

@@ -43,6 +43,10 @@ class Parser(BisonParser):
     docstrings. Scanner rules are in the 'lexscript' attribute.
     docstrings. Scanner rules are in the 'lexscript' attribute.
     """
     """
 
 
+    # Words to be ignored by preprocessor
+    words = zip(*filter(lambda (s, op): TOKEN_MAP[op] == 'FUNCTION', \
+                        OP_MAP.iteritems()))[0] + ('raise', 'graph')
+
     # Output directory of generated pybison files, including a trailing slash.
     # Output directory of generated pybison files, including a trailing slash.
     buildDirectory = PYBISON_BUILD + '/'
     buildDirectory = PYBISON_BUILD + '/'
 
 
@@ -154,14 +158,11 @@ class Parser(BisonParser):
                 + '|([a-z])\s*([0-9])'    # match: a4  result: a ^ 4
                 + '|([a-z])\s*([0-9])'    # match: a4  result: a ^ 4
                 + '|([0-9])\s+([0-9]))')  # match: 4 4 result: 4 * 4
                 + '|([0-9])\s+([0-9]))')  # match: 4 4 result: 4 * 4
 
 
-        words = zip(*filter(lambda (s, op): TOKEN_MAP[op] == 'FUNCTION', \
-                            OP_MAP.iteritems()))[0] + ('raise', 'graph')
-
         def preprocess_data(match):
         def preprocess_data(match):
             left, right = filter(None, match.groups())
             left, right = filter(None, match.groups())
 
 
             # Filter words (otherwise they will be preprocessed as well)
             # Filter words (otherwise they will be preprocessed as well)
-            if left + right in words:
+            if left + right in Parser.words:
                 return left + right
                 return left + right
 
 
             # If all characters on the right are numbers. e.g. "a4", the
             # If all characters on the right are numbers. e.g. "a4", the