diff python/yacc.py @ 396:fb3c1f029b30

Added baselexer into c3 lexer
author Windel Bouwman
date Tue, 27 May 2014 22:19:32 +0200
parents 173e20a47fda
children
line wrap: on
line diff
--- a/python/yacc.py	Fri May 23 14:28:03 2014 +0200
+++ b/python/yacc.py	Tue May 27 22:19:32 2014 +0200
@@ -44,7 +44,7 @@
 import logging
 from pyyacc import Grammar
 from baselex import BaseLexer
-from ppci import Token
+from ppci import Token, SourceLocation
 
 
 class XaccLexer(BaseLexer):
@@ -63,19 +63,20 @@
         section = 0
         for line in lines:
             line = line.strip()
+            loc = SourceLocation(self.filename, 0, 0, 0)
             if not line:
                 continue  # Skip empty lines
             if line == '%%':
                 section += 1
-                yield Token('%%', '%%')
+                yield Token('%%', '%%', loc)
                 continue
             if section == 0:
                 if line.startswith('%tokens'):
-                    yield Token('%tokens', '%tokens')
+                    yield Token('%tokens', '%tokens', loc)
                     for tk in super().tokenize(line[7:]):
                         yield tk
                 else:
-                    yield Token('HEADER', line)
+                    yield Token('HEADER', line, loc)
             elif section == 1:
                 for tk in super().tokenize(line):
                     yield tk