natural works
This commit is contained in:
commit
1c4377b4cb
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/python3
|
||||
import ply.lex
|
||||
tokens = [
|
||||
'NUMBER',
|
||||
'ANY'
|
||||
]
|
||||
|
||||
def t_NUMBER(t):
|
||||
r'[^-\.,(0\d*)]([1-9][0-9]*)'
|
||||
t.value = int(t.value)
|
||||
print(t.value)
|
||||
return t
|
||||
|
||||
def t_error(t):
|
||||
pass
|
||||
|
||||
def t_ANY(t):
|
||||
r'.'
|
||||
pass
|
||||
|
||||
def t_newline(t):
|
||||
r'\n'
|
||||
pass
|
||||
|
||||
lexer = ply.lex.lex()
|
||||
|
||||
data = """
|
||||
This is a text containing five 55 lines, two 2 of which are empty.
|
||||
This is the second 2 non-empty line,
|
||||
and this is the third 3 non-empty line 5758.
|
||||
you are 0
|
||||
|
||||
bad stuff
|
||||
0111001
|
||||
vsadads -500
|
||||
.5
|
||||
0.2324
|
||||
0,2324
|
||||
"""
|
||||
|
||||
lexer.input(data)
|
||||
for t in lexer:
|
||||
pass
|
Loading…
Reference in New Issue