- 注册时间
- 2004-11-27
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2016-9-11 13:55:58
|
显示全部楼层
回复 2# 的帖子
嗯,可能是因为括号比较多吧
我刚才把Yan的编译器中的“函数生成器.txt”丢进这个parser了。
预处理器的结果 - simple void KW_VOID
- emit_simple_directly push void
- identifier FunSeek
- emit_identifier push FunSeek
- simple ( OP_LPAREN
- emit_simple_directly push (
- simple ) OP_RPAREN
- emit_simple_directly push )
- simple { OP_LBRACE
- emit_simple_directly push {
- simple int KW_INT
- emit_simple_directly push int
- identifier i
- emit_identifier push i
- simple , OP_COMMA
- emit_simple_directly push ,
- identifier p
- emit_identifier push p
- simple ; OP_SEMICOLON
- emit_simple_directly push ;
- simple char KW_CHAR
- emit_simple_directly push char
- identifier n
- emit_identifier push n
- simple ; OP_SEMICOLON
- emit_simple_directly push ;
- identifier FunInsert
- emit_identifier push FunInsert
- simple ( OP_LPAREN
- emit_simple_directly push (
- literal "define" array of 7 char 646566696E6500
- simple , OP_COMMA
- emit_simple_directly push ,
- literal 0 int 00000000
- simple | OP_BOR
- emit_simple_directly push |
- identifier SK_BLANK
- emit_identifier push SK_BLANK
- simple << OP_LSHIFT
- emit_simple_directly push <<
- literal 4 int 04000000
- simple ) OP_RPAREN
- emit_simple_directly push )
- simple ; OP_SEMICOLON
- emit_simple_directly push ;
- identifier FunInsert
- emit_identifier push FunInsert
- simple ( OP_LPAREN
- emit_simple_directly push (
- literal "include" array of 8 char 696E636C75646500
- simple , OP_COMMA
- emit_simple_directly push ,
- literal 0 int 00000000
- simple | OP_BOR
- emit_simple_directly push |
- identifier SK_BAO
- emit_identifier push SK_BAO
- simple << OP_LSHIFT
- emit_simple_directly push <<
- literal 4 int 04000000
- simple ) OP_RPAREN
- emit_simple_directly push )
- simple ; OP_SEMICOLON
- emit_simple_directly push ;
- identifier FunInsert
- emit_identifier push FunInsert
- simple ( OP_LPAREN
- emit_simple_directly push (
- literal "undef" array of 6 char 756E64656600
- simple , OP_COMMA
- emit_simple_directly push ,
- literal 0 int 00000000
- simple | OP_BOR
- emit_simple_directly push |
- identifier SK_BLANK
- emit_identifier push SK_BLANK
- simple << OP_LSHIFT
- emit_simple_directly push <<
- literal 4 int 04000000
- simple ) OP_RPAREN
- emit_simple_directly push )
- simple ; OP_SEMICOLON
- emit_simple_directly push ;
- identifier FunInsert
- emit_identifier push FunInsert
- simple ( OP_LPAREN
- emit_simple_directly push (
- literal "ifdef" array of 6 char 696664656600
- simple , OP_COMMA
- emit_simple_directly push ,
- literal 0 int 00000000
- simple | OP_BOR
- emit_simple_directly push |
- identifier SK_BLANK
- emit_identifier push SK_BLANK
- simple << OP_LSHIFT
- emit_simple_directly push <<
- literal 4 int 04000000
- simple ) OP_RPAREN
- emit_simple_directly push )
- simple ; OP_SEMICOLON
- emit_simple_directly push ;
- identifier FunInsert
- emit_identifier push FunInsert
- simple ( OP_LPAREN
- emit_simple_directly push (
- literal "ifndef" array of 7 char 69666E64656600
- simple , OP_COMMA
- emit_simple_directly push ,
- literal 0 int 00000000
- simple | OP_BOR
- emit_simple_directly push |
- identifier SK_BLANK
- emit_identifier push SK_BLANK
- simple << OP_LSHIFT
- emit_simple_directly push <<
- literal 4 int 04000000
- simple ) OP_RPAREN
- emit_simple_directly push )
- simple ; OP_SEMICOLON
- emit_simple_directly push ;
- identifier FunInsert
- emit_identifier push FunInsert
- simple ( OP_LPAREN
- emit_simple_directly push (
- literal "endif" array of 6 char 656E64696600
- simple , OP_COMMA
- emit_simple_directly push ,
- literal 0 int 00000000
- simple ) OP_RPAREN
- emit_simple_directly push )
- simple ; OP_SEMICOLON
- emit_simple_directly push ;
- identifier FunInsert
- emit_identifier push FunInsert
- simple ( OP_LPAREN
- (因为长度限制略去)
- emit_simple_directly push }
- simple } OP_RBRACE
- emit_simple_directly push }
- eof
- We have 589 tokens.
- 0: void
- 1: FunSeek
- 2: (
- 3: )
- 4: {
- 5: int
- 6: i
- 7: ,
- 8: p
- 9: ;
- 10: char
- 11: n
- 12: ;
- 13: FunInsert
- 14: (
- 15: "define"
- 16: ,
- 17: 0
- 18: |
- 19: SK_BLANK
- 20: <<
- 21: 4
- 22: )
- 23: ;
- 24: FunInsert
- 25: (
- 26: "include"
- 27: ,
- 28: 0
- 29: |
- 30: SK_BAO
- 31: <<
- 32: 4
- 33: )
- 34: ;
- 35: FunInsert
- 36: (
- 37: "undef"
- 38: ,
- 39: 0
- 40: |
- 41: SK_BLANK
- 42: <<
- 43: 4
- 44: )
- 45: ;
- 46: FunInsert
- 47: (
- 48: "ifdef"
- 49: ,
- 50: 0
- 51: |
- 52: SK_BLANK
- 53: <<
- 54: 4
- 55: )
- 56: ;
- 57: FunInsert
- 58: (
- 59: "ifndef"
- 60: ,
- 61: 0
- 62: |
- 63: SK_BLANK
- 64: <<
- 65: 4
- 66: )
- 67: ;
- 68: FunInsert
- 69: (
- 70: "endif"
- 71: ,
- 72: 0
- 73: )
- 74: ;
- 75: FunInsert
- 76: (
- 77: "loadall"
- 78: ,
- 79: 0
- 80: |
- 81: SK_CR
- 82: <<
- 83: 4
- 84: )
- 85: ;
- 86: FunInsert
- 87: (
- 88: "secret"
- 89: ,
- 90: 0
- 91: |
- 92: SK_BLANK
- 93: <<
- 94: 4
- 95: )
- 96: ;
- 97: FunInsert
- 98: (
- 99: "code"
- 100: ,
- 101: 0
- 102: |
- 103: SK_NULL
- 104: <<
- 105: 4
- 106: )
- 107: ;
- 108: FunInsert
- 109: (
- 110: "loaddata"
- 111: ,
- 112: 0
- 113: |
- 114: SK_BLANK
- 115: <<
- 116: 4
- 117: )
- 118: ;
- 119: FunInsert
- 120: (
- 121: "begin"
- 122: ,
- 123: 0
- 124: |
- 125: SK_BLANK
- 126: <<
- 127: 4
- 128: )
- 129: ;
- 130: FunInsert
- 131: (
- 132: "end"
- 133: ,
- 134: 0
- 135: |
- 136: SK_CR
- 137: <<
- 138: 4
- (因为长度限制略去)
- 571: )
- 572: n
- 573: =
- 574: 1
- 575: ;
- 576: FunInsert
- 577: (
- 578: p
- 579: ,
- 580: n
- 581: |
- 582: SK_FUN
- 583: <<
- 584: 4
- 585: )
- 586: ;
- 587: }
- 588: }
复制代码
[ 本帖最后由 cs900601 于 2016-9-11 00:01 编辑 ] |
|