Mercurial > lcfOS
diff python/ppci/c3/lexer.py @ 305:0615b5308710
Updated docs
author | Windel Bouwman |
---|---|
date | Fri, 06 Dec 2013 13:50:38 +0100 |
parents | 158068af716c |
children | b145f8e6050b |
line wrap: on
line diff
--- a/python/ppci/c3/lexer.py Fri Dec 06 12:45:02 2013 +0100 +++ b/python/ppci/c3/lexer.py Fri Dec 06 13:50:38 2013 +0100 @@ -8,13 +8,14 @@ """ keywords = ['and', 'or', 'not', 'true', 'false', - 'else', 'if', 'while', 'return', - 'function', 'var', 'type', 'const', - 'struct', 'cast', - 'import', 'module'] + 'else', 'if', 'while', 'return', + 'function', 'var', 'type', 'const', + 'struct', 'cast', + 'import', 'module'] class Lexer: + """ Generates a sequence of token from an input stream """ def __init__(self, diag): self.diag = diag @@ -65,7 +66,7 @@ elif typ == 'SKIP': pass elif incomment: - pass # Wait until we are not in a comment section + pass # Wait until we are not in a comment section else: if typ == 'ID': if val in keywords: @@ -82,7 +83,7 @@ elif typ == 'STRING': val = val[1:-1] loc = SourceLocation(filename, line, mo.start() - line_start, - mo.end() - mo.start()) + mo.end() - mo.start()) yield Token(typ, val, loc) pos = mo.end() mo = gettok(s, pos)