unable to parse correctly
- Dominant language
- Java
- Stars
- 19k
- Forks
- 3.5k
- PR merge metrics
- No merged PRs in 30d
Description
Hi all
I am using antlr4 and i want to parse this:
```
(bits 64){
aaa
}
```
IF i delete this line **"code16_32 : 'aaa'"** in my grammar, it can parse, why? It shouldn't jump into rule "code16_32". Please help !!!
My grammar is :
```
grammar Assembler;
WS : [ \t]+ -> skip;
NL : '\r'? '\n' -> skip;
LINE_COMMENT : ';' ~[\r\n]*;
INSTRUCTION : [a-z]+;
IDENTIFIER : [a-zA-Z] [a-zA-Z0-9]+;
SECTION_NAME : '.' IDENTIFIER;
LABEL_POSTFIX : 'equ' ~[;]*;
assemble : lines
| EOF
;
lines : line*
;
line : bits64
;
comment : LINE_COMMENT
;
code16_32_64 : 'DUMMY'
;
code16 : 'DUMMY'
;
code16_32 : 'aaa' # aaa
| 'aad' # aad
| 'aad' IMM8 # aad_imm8
| 'aam' # aam
| 'aam' IMM8 # aam_imm8
| 'aas' # aas
| 'adc' AL ',' IMM8 # adc_imm8
| 'adc' AX ',' IMM16 # adc_imm16
;
code32 : INSTRUCTION
;
code32_64 : INSTRUCTION
;
code64 : INSTRUCTION {System.err.println("fuck");}
;
data : 'db' STRING ',' NUMBER
;
bits64 : '(bits 64){' (code64 | code32_64 | code16_32_64)* comment? '}'
;
```
Thanks
From Peter
Contributor guide
Research direction
Start with the sample input and the complete Assembler grammar in the issue, then trace how the lexer and parser select among code64, code32_64, code16_32_64, and code16_32. Run the grammar against the `(bits 64){ aaa }` example and compare behavior with and without the `code16_32` rule; done means explaining the differing parse result.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100