Files
h2inc-old/lexer/lexer.py
2018-07-17 11:51:38 +02:00

22 lines
502 B
Python

# (c) 2018 Jan Lerking
# Python lexer for c header files.
# Used for creating corresponding NASM include files.
import keywords
import os
keywords.init()
lexed_line = []
def lex_line(l):
prep = keywords.preprocessor_directives
reg = keywords.regular
for w in l:
if w in prep:
lexed_line.append(prep(w))
lexed_line.append(w)
break
if w in reg:
lexed_line.append(reg(w))
lexed_line.append(w)