From 04ecc8b946b3519ad18ef58a2867b239d4ec53da Mon Sep 17 00:00:00 2001 From: Taddeus Kroes <taddeuskroes@hotmail.com> Date: Sun, 26 Feb 2012 14:39:03 +0100 Subject: [PATCH] Made 'words' variable static. --- src/parser.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/parser.py b/src/parser.py index 123d55d..17d1c9f 100644 --- a/src/parser.py +++ b/src/parser.py @@ -43,6 +43,10 @@ class Parser(BisonParser): 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. buildDirectory = PYBISON_BUILD + '/' @@ -154,14 +158,11 @@ class Parser(BisonParser): + '|([a-z])\s*([0-9])' # match: a4 result: a ^ 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): left, right = filter(None, match.groups()) # Filter words (otherwise they will be preprocessed as well) - if left + right in words: + if left + right in Parser.words: return left + right # If all characters on the right are numbers. e.g. "a4", the -- GitLab