-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f1e3d8
commit 8fcd5a1
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# FAQ | ||
|
||
## 为什么我的 lexer/parser 卡住了 | ||
|
||
flex/bison 默认从 `stdin` 读入输入, 由于 `\n` 也会视为输入的一部分, 你需要手动输入 `EOF` 结束, 这在 `bash` 上是 `Ctrl+D`. | ||
|
||
如果你想从文件里输入的话 (比如 `./compiler test.in`), 这里提供一个供参考的解决方法: | ||
|
||
```cpp | ||
extern int yyparse(); | ||
|
||
extern FILE* yyin; | ||
|
||
int main(int argc, char **argv) { | ||
yyin = fopen(argv[1], "r"); | ||
yyparse(); | ||
return 0; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters