Skip to content

Instantly share code, notes, and snippets.

View CeperaCPP's full-sized avatar

Sergey CeperaCPP

  • Moscow
View GitHub Profile
@CeperaCPP
CeperaCPP / cc.py
Created March 20, 2017 14:53 — forked from anonymous/cc.py
Useless C subset compiler
#!/usr/bin/env python
import sys
class Lexer:
NUM, ID, IF, ELSE, WHILE, DO, LBRA, RBRA, LPAR, RPAR, PLUS, MINUS, LESS, \
EQUAL, SEMICOLON, EOF = range(16)
SYMBOLS = { '{': LBRA, '}': RBRA, '=': EQUAL, ';': SEMICOLON, '(': LPAR,