Skip to content

Instantly share code, notes, and snippets.

@vedgar
Created April 23, 2020 07:19
Show Gist options
  • Save vedgar/07d5d5119a26301d8ffd9437c38c9d0a to your computer and use it in GitHub Desktop.
Save vedgar/07d5d5119a26301d8ffd9437c38c9d0a to your computer and use it in GitHub Desktop.
def ls_lex(kôd):
lex = Tokenizer(kôd)
for znak in iter(lex.čitaj, ''):
if znak == 'P':
lex.plus(str.isdigit)
n = lex.sadržaj.lstrip('P')
if n != str(int(n)): raise lex.greška('Vodeća 0')
yield lex.token(LS.PVAR)
continue
if znak == '<': znak = lex.čitaj() # fallthrough
if znak == '-': lex.čitaj()
yield lex.literal(LS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment