2022 Spring NTUT Compiler Program1 - Scanner === # Authors 資工碩二 黃國豪 109598074 資工碩二 吳承岳 109598085 共同開發 # About 本次作業設計一個支援部分語法的 c 語言 Scanner 參考 [c4](https://github.com/rswier/c4) 使用 flex 作為開發工具 測試檔案為 hello.c [Github](https://github.com/Vynax/c4_compiler/tree/dev) # Build Run the following command to build: ```shell= $ flex prog1.l $ gcc lex.yy.c -o prog1 ``` Run test: ```shell= $ ./prog1 < hello.c or $ ./prog1 hello.c ``` Output shows on the screen ``` INT MAIN PUNCT('(') PUNCT(')') PUNCT('{') INT ID(i) ASSIGN NUM(0) PUNCT(';') ID(while) PUNCT('(') ID(i) LT NUM(5) PUNCT(')') PUNCT('{') ID(printf) PUNCT('(') DIV PUNCT(')') PUNCT(';') ID(i) ASSIGN ID(i) ADD NUM(1) PUNCT(';') PUNCT('}') ID(return) NUM(0) PUNCT(';') PUNCT('}') ```