natural works

This commit is contained in:
Christoph J. Scherr 2023-12-17 16:51:20 +01:00
commit 1c4377b4cb
1 changed files with 43 additions and 0 deletions

43
src/find-natural.py Normal file
View File

@ -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