Tokenize strings.

pull/15/head
Jussi Pakkanen 12 years ago
parent 5ab7588873
commit 802d56d135
  1. 6
      builder.py

@ -23,7 +23,8 @@ tokens = ['LPAREN',
'COMMENT', 'COMMENT',
'EQUALS', 'EQUALS',
'COMMA', 'COMMA',
'DOT'] 'DOT',
'STRING']
t_EQUALS = '=' t_EQUALS = '='
t_LPAREN = '\(' t_LPAREN = '\('
@ -32,6 +33,7 @@ t_VARIABLE = '[a-zA-Z][_0-9a-zA-Z]*'
t_COMMENT = '\#[^\n]*' t_COMMENT = '\#[^\n]*'
t_COMMA = ',' t_COMMA = ','
t_DOT = '\.' t_DOT = '\.'
t_STRING = "'[^']*'"
t_ignore = ' \t\n' t_ignore = ' \t\n'
@ -42,7 +44,7 @@ def t_error(t):
def test_lexer(): def test_lexer():
s = """hello = (something) # this = (that) s = """hello = (something) # this = (that)
function(h) function(h)
obj.method(lll) obj.method(lll, 'string')
""" """
lexer = lex.lex() lexer = lex.lex()
lexer.input(s) lexer.input(s)

Loading…
Cancel
Save