comparison test/testpyy.py @ 396:fb3c1f029b30

Added baselexer into c3 lexer
author Windel Bouwman
date Tue, 27 May 2014 22:19:32 +0200
parents 4d204f6f7d4e
children
comparison
equal deleted inserted replaced
395:3b0c495e3008 396:fb3c1f029b30
1 import unittest 1 import unittest
2 from pyyacc import Grammar, Item, ParserGenerationException, ParserException 2 from pyyacc import Grammar, Item, ParserGenerationException, ParserException
3 from pyyacc import EPS, EOF, calculate_first_sets 3 from pyyacc import EPS, EOF, calculate_first_sets
4 from ppci import Token 4 from ppci import Token, SourceLocation
5 5
6 6
7 class genTokens: 7 class genTokens:
8 def __init__(self, lst): 8 def __init__(self, lst):
9 def tokGen(): 9 def tokGen():
10 loc = SourceLocation('', 0, 0, 0)
10 for t in lst: 11 for t in lst:
11 yield Token(t, t) 12 yield Token(t, t, loc)
12 while True: 13 while True:
13 yield Token(EOF, EOF) 14 yield Token(EOF, EOF, loc)
14 self.tokens = tokGen() 15 self.tokens = tokGen()
15 self.token = self.tokens.__next__() 16 self.token = self.tokens.__next__()
16 17
17 def next_token(self): 18 def next_token(self):
18 t = self.token 19 t = self.token