Added 'lexer' file test

This commit is contained in:
Lerking
2018-07-17 11:51:38 +02:00
committed by GitHub
parent 8fa5db1da1
commit 8ff9e5136a
5 changed files with 422 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
# (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)