Update grammar for Condition ShortCut
This commit is contained in:
parent
ed1f6d52d8
commit
d87a5151eb
@ -36,13 +36,13 @@ BraceWrapping:
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
@ -50,7 +50,7 @@ BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
ColumnLimit: 120
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
|
||||
4
Sysy.g4
4
Sysy.g4
@ -79,9 +79,9 @@ relExp: addExp | relExp ('<' | '>' | '<=' | '>=') addExp;
|
||||
|
||||
eqExp: relExp | eqExp ('==' | '!=') relExp;
|
||||
|
||||
lAndExp: eqExp | lAndExp '&&' eqExp;
|
||||
lAndExp: eqExp ('&&' eqExp)*;
|
||||
|
||||
lOrExp: lAndExp | lOrExp '||' lAndExp;
|
||||
lOrExp: lAndExp ('||' lAndExp)*;
|
||||
|
||||
constExp: addExp; // 注:使用的 Ident 必须是常量
|
||||
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
#include "llir_value.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace antlrSysY {
|
||||
@ -687,32 +689,38 @@ public:
|
||||
public:
|
||||
LAndExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
EqExpContext *eqExp();
|
||||
LAndExpContext *lAndExp();
|
||||
antlr4::tree::TerminalNode *AND();
|
||||
std::vector<EqExpContext *> eqExp();
|
||||
EqExpContext* eqExp(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> AND();
|
||||
antlr4::tree::TerminalNode* AND(size_t i);
|
||||
|
||||
BasicBlockPtr_t true_block;
|
||||
BasicBlockPtr_t false_block;
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
LAndExpContext* lAndExp();
|
||||
LAndExpContext* lAndExp(int precedence);
|
||||
|
||||
class LOrExpContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
LOrExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
LAndExpContext *lAndExp();
|
||||
LOrExpContext *lOrExp();
|
||||
antlr4::tree::TerminalNode *OR();
|
||||
std::vector<LAndExpContext *> lAndExp();
|
||||
LAndExpContext* lAndExp(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> OR();
|
||||
antlr4::tree::TerminalNode* OR(size_t i);
|
||||
|
||||
BasicBlockPtr_t true_block;
|
||||
BasicBlockPtr_t false_block;
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
LOrExpContext* lOrExp();
|
||||
LOrExpContext* lOrExp(int precedence);
|
||||
|
||||
class ConstExpContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
ConstExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
@ -733,8 +741,6 @@ public:
|
||||
bool addExpSempred(AddExpContext *_localctx, size_t predicateIndex);
|
||||
bool relExpSempred(RelExpContext *_localctx, size_t predicateIndex);
|
||||
bool eqExpSempred(EqExpContext *_localctx, size_t predicateIndex);
|
||||
bool lAndExpSempred(LAndExpContext *_localctx, size_t predicateIndex);
|
||||
bool lOrExpSempred(LOrExpContext *_localctx, size_t predicateIndex);
|
||||
|
||||
// By default the static state used to implement the parser is lazily initialized during the first
|
||||
// call to the constructor. You can call this function if you wish to initialize the static state
|
||||
|
||||
@ -67,7 +67,7 @@ void sysyParserInitialize() {
|
||||
}
|
||||
);
|
||||
static const int32_t serializedATNSegment[] = {
|
||||
4,1,41,366,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,
|
||||
4,1,41,360,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,
|
||||
7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,
|
||||
14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,
|
||||
21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,
|
||||
@ -93,99 +93,97 @@ void sysyParserInitialize() {
|
||||
8,27,10,27,12,27,307,9,27,1,28,1,28,1,28,1,28,1,28,1,28,5,28,315,8,28,
|
||||
10,28,12,28,318,9,28,1,29,1,29,1,29,1,29,1,29,1,29,5,29,326,8,29,10,29,
|
||||
12,29,329,9,29,1,30,1,30,1,30,1,30,1,30,1,30,5,30,337,8,30,10,30,12,30,
|
||||
340,9,30,1,31,1,31,1,31,1,31,1,31,1,31,5,31,348,8,31,10,31,12,31,351,
|
||||
9,31,1,32,1,32,1,32,1,32,1,32,1,32,5,32,359,8,32,10,32,12,32,362,9,32,
|
||||
1,33,1,33,1,33,0,6,54,56,58,60,62,64,34,0,2,4,6,8,10,12,14,16,18,20,22,
|
||||
24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,0,7,
|
||||
2,0,4,4,12,12,1,0,35,37,1,0,19,21,1,0,22,24,1,0,19,20,1,0,25,28,1,0,29,
|
||||
30,375,0,68,1,0,0,0,2,72,1,0,0,0,4,78,1,0,0,0,6,80,1,0,0,0,8,92,1,0,0,
|
||||
0,10,94,1,0,0,0,12,120,1,0,0,0,14,122,1,0,0,0,16,133,1,0,0,0,18,160,1,
|
||||
0,0,0,20,162,1,0,0,0,22,171,1,0,0,0,24,173,1,0,0,0,26,181,1,0,0,0,28,
|
||||
196,1,0,0,0,30,207,1,0,0,0,32,243,1,0,0,0,34,245,1,0,0,0,36,247,1,0,0,
|
||||
0,38,249,1,0,0,0,40,265,1,0,0,0,42,267,1,0,0,0,44,269,1,0,0,0,46,281,
|
||||
1,0,0,0,48,283,1,0,0,0,50,285,1,0,0,0,52,295,1,0,0,0,54,297,1,0,0,0,56,
|
||||
308,1,0,0,0,58,319,1,0,0,0,60,330,1,0,0,0,62,341,1,0,0,0,64,352,1,0,0,
|
||||
0,66,363,1,0,0,0,68,69,3,2,1,0,69,1,1,0,0,0,70,73,3,20,10,0,71,73,3,4,
|
||||
2,0,72,70,1,0,0,0,72,71,1,0,0,0,73,74,1,0,0,0,74,72,1,0,0,0,74,75,1,0,
|
||||
0,0,75,3,1,0,0,0,76,79,3,6,3,0,77,79,3,14,7,0,78,76,1,0,0,0,78,77,1,0,
|
||||
0,0,79,5,1,0,0,0,80,81,5,1,0,0,81,82,3,8,4,0,82,87,3,10,5,0,83,84,5,2,
|
||||
0,0,84,86,3,10,5,0,85,83,1,0,0,0,86,89,1,0,0,0,87,85,1,0,0,0,87,88,1,
|
||||
0,0,0,88,90,1,0,0,0,89,87,1,0,0,0,90,91,5,3,0,0,91,7,1,0,0,0,92,93,5,
|
||||
4,0,0,93,9,1,0,0,0,94,101,5,34,0,0,95,96,5,5,0,0,96,97,3,66,33,0,97,98,
|
||||
5,6,0,0,98,100,1,0,0,0,99,95,1,0,0,0,100,103,1,0,0,0,101,99,1,0,0,0,101,
|
||||
102,1,0,0,0,102,104,1,0,0,0,103,101,1,0,0,0,104,105,5,7,0,0,105,106,3,
|
||||
12,6,0,106,11,1,0,0,0,107,121,3,66,33,0,108,117,5,8,0,0,109,114,3,12,
|
||||
6,0,110,111,5,2,0,0,111,113,3,12,6,0,112,110,1,0,0,0,113,116,1,0,0,0,
|
||||
114,112,1,0,0,0,114,115,1,0,0,0,115,118,1,0,0,0,116,114,1,0,0,0,117,109,
|
||||
1,0,0,0,117,118,1,0,0,0,118,119,1,0,0,0,119,121,5,9,0,0,120,107,1,0,0,
|
||||
0,120,108,1,0,0,0,121,13,1,0,0,0,122,123,3,8,4,0,123,128,3,16,8,0,124,
|
||||
125,5,2,0,0,125,127,3,16,8,0,126,124,1,0,0,0,127,130,1,0,0,0,128,126,
|
||||
1,0,0,0,128,129,1,0,0,0,129,131,1,0,0,0,130,128,1,0,0,0,131,132,5,3,0,
|
||||
0,132,15,1,0,0,0,133,140,5,34,0,0,134,135,5,5,0,0,135,136,3,66,33,0,136,
|
||||
137,5,6,0,0,137,139,1,0,0,0,138,134,1,0,0,0,139,142,1,0,0,0,140,138,1,
|
||||
0,0,0,140,141,1,0,0,0,141,145,1,0,0,0,142,140,1,0,0,0,143,144,5,7,0,0,
|
||||
144,146,3,18,9,0,145,143,1,0,0,0,145,146,1,0,0,0,146,17,1,0,0,0,147,161,
|
||||
3,34,17,0,148,157,5,8,0,0,149,154,3,18,9,0,150,151,5,2,0,0,151,153,3,
|
||||
18,9,0,152,150,1,0,0,0,153,156,1,0,0,0,154,152,1,0,0,0,154,155,1,0,0,
|
||||
0,155,158,1,0,0,0,156,154,1,0,0,0,157,149,1,0,0,0,157,158,1,0,0,0,158,
|
||||
159,1,0,0,0,159,161,5,9,0,0,160,147,1,0,0,0,160,148,1,0,0,0,161,19,1,
|
||||
0,0,0,162,163,3,22,11,0,163,164,5,34,0,0,164,166,5,10,0,0,165,167,3,24,
|
||||
12,0,166,165,1,0,0,0,166,167,1,0,0,0,167,168,1,0,0,0,168,169,5,11,0,0,
|
||||
169,170,3,28,14,0,170,21,1,0,0,0,171,172,7,0,0,0,172,23,1,0,0,0,173,178,
|
||||
3,26,13,0,174,175,5,2,0,0,175,177,3,26,13,0,176,174,1,0,0,0,177,180,1,
|
||||
0,0,0,178,176,1,0,0,0,178,179,1,0,0,0,179,25,1,0,0,0,180,178,1,0,0,0,
|
||||
181,182,3,8,4,0,182,194,5,34,0,0,183,184,5,5,0,0,184,191,5,6,0,0,185,
|
||||
186,5,5,0,0,186,187,3,34,17,0,187,188,5,6,0,0,188,190,1,0,0,0,189,185,
|
||||
1,0,0,0,190,193,1,0,0,0,191,189,1,0,0,0,191,192,1,0,0,0,192,195,1,0,0,
|
||||
0,193,191,1,0,0,0,194,183,1,0,0,0,194,195,1,0,0,0,195,27,1,0,0,0,196,
|
||||
200,5,8,0,0,197,199,3,30,15,0,198,197,1,0,0,0,199,202,1,0,0,0,200,198,
|
||||
1,0,0,0,200,201,1,0,0,0,201,203,1,0,0,0,202,200,1,0,0,0,203,204,5,9,0,
|
||||
0,204,29,1,0,0,0,205,208,3,4,2,0,206,208,3,32,16,0,207,205,1,0,0,0,207,
|
||||
206,1,0,0,0,208,31,1,0,0,0,209,210,3,38,19,0,210,211,5,7,0,0,211,212,
|
||||
3,34,17,0,212,213,5,3,0,0,213,244,1,0,0,0,214,216,3,34,17,0,215,214,1,
|
||||
0,0,0,215,216,1,0,0,0,216,217,1,0,0,0,217,244,5,3,0,0,218,244,3,28,14,
|
||||
0,219,220,5,13,0,0,220,221,5,10,0,0,221,222,3,36,18,0,222,223,5,11,0,
|
||||
0,223,226,3,32,16,0,224,225,5,14,0,0,225,227,3,32,16,0,226,224,1,0,0,
|
||||
0,226,227,1,0,0,0,227,244,1,0,0,0,228,229,5,15,0,0,229,230,5,10,0,0,230,
|
||||
231,3,36,18,0,231,232,5,11,0,0,232,233,3,32,16,0,233,244,1,0,0,0,234,
|
||||
235,5,16,0,0,235,244,5,3,0,0,236,237,5,17,0,0,237,244,5,3,0,0,238,240,
|
||||
5,18,0,0,239,241,3,34,17,0,240,239,1,0,0,0,240,241,1,0,0,0,241,242,1,
|
||||
0,0,0,242,244,5,3,0,0,243,209,1,0,0,0,243,215,1,0,0,0,243,218,1,0,0,0,
|
||||
243,219,1,0,0,0,243,228,1,0,0,0,243,234,1,0,0,0,243,236,1,0,0,0,243,238,
|
||||
1,0,0,0,244,33,1,0,0,0,245,246,3,56,28,0,246,35,1,0,0,0,247,248,3,64,
|
||||
32,0,248,37,1,0,0,0,249,256,5,34,0,0,250,251,5,5,0,0,251,252,3,34,17,
|
||||
0,252,253,5,6,0,0,253,255,1,0,0,0,254,250,1,0,0,0,255,258,1,0,0,0,256,
|
||||
254,1,0,0,0,256,257,1,0,0,0,257,39,1,0,0,0,258,256,1,0,0,0,259,260,5,
|
||||
10,0,0,260,261,3,34,17,0,261,262,5,11,0,0,262,266,1,0,0,0,263,266,3,38,
|
||||
19,0,264,266,3,42,21,0,265,259,1,0,0,0,265,263,1,0,0,0,265,264,1,0,0,
|
||||
0,266,41,1,0,0,0,267,268,3,44,22,0,268,43,1,0,0,0,269,270,7,1,0,0,270,
|
||||
45,1,0,0,0,271,282,3,40,20,0,272,273,5,34,0,0,273,275,5,10,0,0,274,276,
|
||||
3,50,25,0,275,274,1,0,0,0,275,276,1,0,0,0,276,277,1,0,0,0,277,282,5,11,
|
||||
0,0,278,279,3,48,24,0,279,280,3,46,23,0,280,282,1,0,0,0,281,271,1,0,0,
|
||||
0,281,272,1,0,0,0,281,278,1,0,0,0,282,47,1,0,0,0,283,284,7,2,0,0,284,
|
||||
49,1,0,0,0,285,290,3,52,26,0,286,287,5,2,0,0,287,289,3,52,26,0,288,286,
|
||||
1,0,0,0,289,292,1,0,0,0,290,288,1,0,0,0,290,291,1,0,0,0,291,51,1,0,0,
|
||||
0,292,290,1,0,0,0,293,296,3,34,17,0,294,296,5,41,0,0,295,293,1,0,0,0,
|
||||
295,294,1,0,0,0,296,53,1,0,0,0,297,298,6,27,-1,0,298,299,3,46,23,0,299,
|
||||
305,1,0,0,0,300,301,10,1,0,0,301,302,7,3,0,0,302,304,3,46,23,0,303,300,
|
||||
1,0,0,0,304,307,1,0,0,0,305,303,1,0,0,0,305,306,1,0,0,0,306,55,1,0,0,
|
||||
0,307,305,1,0,0,0,308,309,6,28,-1,0,309,310,3,54,27,0,310,316,1,0,0,0,
|
||||
311,312,10,1,0,0,312,313,7,4,0,0,313,315,3,54,27,0,314,311,1,0,0,0,315,
|
||||
318,1,0,0,0,316,314,1,0,0,0,316,317,1,0,0,0,317,57,1,0,0,0,318,316,1,
|
||||
0,0,0,319,320,6,29,-1,0,320,321,3,56,28,0,321,327,1,0,0,0,322,323,10,
|
||||
1,0,0,323,324,7,5,0,0,324,326,3,56,28,0,325,322,1,0,0,0,326,329,1,0,0,
|
||||
0,327,325,1,0,0,0,327,328,1,0,0,0,328,59,1,0,0,0,329,327,1,0,0,0,330,
|
||||
331,6,30,-1,0,331,332,3,58,29,0,332,338,1,0,0,0,333,334,10,1,0,0,334,
|
||||
335,7,6,0,0,335,337,3,58,29,0,336,333,1,0,0,0,337,340,1,0,0,0,338,336,
|
||||
1,0,0,0,338,339,1,0,0,0,339,61,1,0,0,0,340,338,1,0,0,0,341,342,6,31,-1,
|
||||
0,342,343,3,60,30,0,343,349,1,0,0,0,344,345,10,1,0,0,345,346,5,31,0,0,
|
||||
346,348,3,60,30,0,347,344,1,0,0,0,348,351,1,0,0,0,349,347,1,0,0,0,349,
|
||||
350,1,0,0,0,350,63,1,0,0,0,351,349,1,0,0,0,352,353,6,32,-1,0,353,354,
|
||||
3,62,31,0,354,360,1,0,0,0,355,356,10,1,0,0,356,357,5,32,0,0,357,359,3,
|
||||
62,31,0,358,355,1,0,0,0,359,362,1,0,0,0,360,358,1,0,0,0,360,361,1,0,0,
|
||||
0,361,65,1,0,0,0,362,360,1,0,0,0,363,364,3,56,28,0,364,67,1,0,0,0,36,
|
||||
72,74,78,87,101,114,117,120,128,140,145,154,157,160,166,178,191,194,200,
|
||||
207,215,226,240,243,256,265,275,281,290,295,305,316,327,338,349,360
|
||||
340,9,30,1,31,1,31,1,31,5,31,345,8,31,10,31,12,31,348,9,31,1,32,1,32,
|
||||
1,32,5,32,353,8,32,10,32,12,32,356,9,32,1,33,1,33,1,33,0,4,54,56,58,60,
|
||||
34,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,
|
||||
48,50,52,54,56,58,60,62,64,66,0,7,2,0,4,4,12,12,1,0,35,37,1,0,19,21,1,
|
||||
0,22,24,1,0,19,20,1,0,25,28,1,0,29,30,369,0,68,1,0,0,0,2,72,1,0,0,0,4,
|
||||
78,1,0,0,0,6,80,1,0,0,0,8,92,1,0,0,0,10,94,1,0,0,0,12,120,1,0,0,0,14,
|
||||
122,1,0,0,0,16,133,1,0,0,0,18,160,1,0,0,0,20,162,1,0,0,0,22,171,1,0,0,
|
||||
0,24,173,1,0,0,0,26,181,1,0,0,0,28,196,1,0,0,0,30,207,1,0,0,0,32,243,
|
||||
1,0,0,0,34,245,1,0,0,0,36,247,1,0,0,0,38,249,1,0,0,0,40,265,1,0,0,0,42,
|
||||
267,1,0,0,0,44,269,1,0,0,0,46,281,1,0,0,0,48,283,1,0,0,0,50,285,1,0,0,
|
||||
0,52,295,1,0,0,0,54,297,1,0,0,0,56,308,1,0,0,0,58,319,1,0,0,0,60,330,
|
||||
1,0,0,0,62,341,1,0,0,0,64,349,1,0,0,0,66,357,1,0,0,0,68,69,3,2,1,0,69,
|
||||
1,1,0,0,0,70,73,3,20,10,0,71,73,3,4,2,0,72,70,1,0,0,0,72,71,1,0,0,0,73,
|
||||
74,1,0,0,0,74,72,1,0,0,0,74,75,1,0,0,0,75,3,1,0,0,0,76,79,3,6,3,0,77,
|
||||
79,3,14,7,0,78,76,1,0,0,0,78,77,1,0,0,0,79,5,1,0,0,0,80,81,5,1,0,0,81,
|
||||
82,3,8,4,0,82,87,3,10,5,0,83,84,5,2,0,0,84,86,3,10,5,0,85,83,1,0,0,0,
|
||||
86,89,1,0,0,0,87,85,1,0,0,0,87,88,1,0,0,0,88,90,1,0,0,0,89,87,1,0,0,0,
|
||||
90,91,5,3,0,0,91,7,1,0,0,0,92,93,5,4,0,0,93,9,1,0,0,0,94,101,5,34,0,0,
|
||||
95,96,5,5,0,0,96,97,3,66,33,0,97,98,5,6,0,0,98,100,1,0,0,0,99,95,1,0,
|
||||
0,0,100,103,1,0,0,0,101,99,1,0,0,0,101,102,1,0,0,0,102,104,1,0,0,0,103,
|
||||
101,1,0,0,0,104,105,5,7,0,0,105,106,3,12,6,0,106,11,1,0,0,0,107,121,3,
|
||||
66,33,0,108,117,5,8,0,0,109,114,3,12,6,0,110,111,5,2,0,0,111,113,3,12,
|
||||
6,0,112,110,1,0,0,0,113,116,1,0,0,0,114,112,1,0,0,0,114,115,1,0,0,0,115,
|
||||
118,1,0,0,0,116,114,1,0,0,0,117,109,1,0,0,0,117,118,1,0,0,0,118,119,1,
|
||||
0,0,0,119,121,5,9,0,0,120,107,1,0,0,0,120,108,1,0,0,0,121,13,1,0,0,0,
|
||||
122,123,3,8,4,0,123,128,3,16,8,0,124,125,5,2,0,0,125,127,3,16,8,0,126,
|
||||
124,1,0,0,0,127,130,1,0,0,0,128,126,1,0,0,0,128,129,1,0,0,0,129,131,1,
|
||||
0,0,0,130,128,1,0,0,0,131,132,5,3,0,0,132,15,1,0,0,0,133,140,5,34,0,0,
|
||||
134,135,5,5,0,0,135,136,3,66,33,0,136,137,5,6,0,0,137,139,1,0,0,0,138,
|
||||
134,1,0,0,0,139,142,1,0,0,0,140,138,1,0,0,0,140,141,1,0,0,0,141,145,1,
|
||||
0,0,0,142,140,1,0,0,0,143,144,5,7,0,0,144,146,3,18,9,0,145,143,1,0,0,
|
||||
0,145,146,1,0,0,0,146,17,1,0,0,0,147,161,3,34,17,0,148,157,5,8,0,0,149,
|
||||
154,3,18,9,0,150,151,5,2,0,0,151,153,3,18,9,0,152,150,1,0,0,0,153,156,
|
||||
1,0,0,0,154,152,1,0,0,0,154,155,1,0,0,0,155,158,1,0,0,0,156,154,1,0,0,
|
||||
0,157,149,1,0,0,0,157,158,1,0,0,0,158,159,1,0,0,0,159,161,5,9,0,0,160,
|
||||
147,1,0,0,0,160,148,1,0,0,0,161,19,1,0,0,0,162,163,3,22,11,0,163,164,
|
||||
5,34,0,0,164,166,5,10,0,0,165,167,3,24,12,0,166,165,1,0,0,0,166,167,1,
|
||||
0,0,0,167,168,1,0,0,0,168,169,5,11,0,0,169,170,3,28,14,0,170,21,1,0,0,
|
||||
0,171,172,7,0,0,0,172,23,1,0,0,0,173,178,3,26,13,0,174,175,5,2,0,0,175,
|
||||
177,3,26,13,0,176,174,1,0,0,0,177,180,1,0,0,0,178,176,1,0,0,0,178,179,
|
||||
1,0,0,0,179,25,1,0,0,0,180,178,1,0,0,0,181,182,3,8,4,0,182,194,5,34,0,
|
||||
0,183,184,5,5,0,0,184,191,5,6,0,0,185,186,5,5,0,0,186,187,3,34,17,0,187,
|
||||
188,5,6,0,0,188,190,1,0,0,0,189,185,1,0,0,0,190,193,1,0,0,0,191,189,1,
|
||||
0,0,0,191,192,1,0,0,0,192,195,1,0,0,0,193,191,1,0,0,0,194,183,1,0,0,0,
|
||||
194,195,1,0,0,0,195,27,1,0,0,0,196,200,5,8,0,0,197,199,3,30,15,0,198,
|
||||
197,1,0,0,0,199,202,1,0,0,0,200,198,1,0,0,0,200,201,1,0,0,0,201,203,1,
|
||||
0,0,0,202,200,1,0,0,0,203,204,5,9,0,0,204,29,1,0,0,0,205,208,3,4,2,0,
|
||||
206,208,3,32,16,0,207,205,1,0,0,0,207,206,1,0,0,0,208,31,1,0,0,0,209,
|
||||
210,3,38,19,0,210,211,5,7,0,0,211,212,3,34,17,0,212,213,5,3,0,0,213,244,
|
||||
1,0,0,0,214,216,3,34,17,0,215,214,1,0,0,0,215,216,1,0,0,0,216,217,1,0,
|
||||
0,0,217,244,5,3,0,0,218,244,3,28,14,0,219,220,5,13,0,0,220,221,5,10,0,
|
||||
0,221,222,3,36,18,0,222,223,5,11,0,0,223,226,3,32,16,0,224,225,5,14,0,
|
||||
0,225,227,3,32,16,0,226,224,1,0,0,0,226,227,1,0,0,0,227,244,1,0,0,0,228,
|
||||
229,5,15,0,0,229,230,5,10,0,0,230,231,3,36,18,0,231,232,5,11,0,0,232,
|
||||
233,3,32,16,0,233,244,1,0,0,0,234,235,5,16,0,0,235,244,5,3,0,0,236,237,
|
||||
5,17,0,0,237,244,5,3,0,0,238,240,5,18,0,0,239,241,3,34,17,0,240,239,1,
|
||||
0,0,0,240,241,1,0,0,0,241,242,1,0,0,0,242,244,5,3,0,0,243,209,1,0,0,0,
|
||||
243,215,1,0,0,0,243,218,1,0,0,0,243,219,1,0,0,0,243,228,1,0,0,0,243,234,
|
||||
1,0,0,0,243,236,1,0,0,0,243,238,1,0,0,0,244,33,1,0,0,0,245,246,3,56,28,
|
||||
0,246,35,1,0,0,0,247,248,3,64,32,0,248,37,1,0,0,0,249,256,5,34,0,0,250,
|
||||
251,5,5,0,0,251,252,3,34,17,0,252,253,5,6,0,0,253,255,1,0,0,0,254,250,
|
||||
1,0,0,0,255,258,1,0,0,0,256,254,1,0,0,0,256,257,1,0,0,0,257,39,1,0,0,
|
||||
0,258,256,1,0,0,0,259,260,5,10,0,0,260,261,3,34,17,0,261,262,5,11,0,0,
|
||||
262,266,1,0,0,0,263,266,3,38,19,0,264,266,3,42,21,0,265,259,1,0,0,0,265,
|
||||
263,1,0,0,0,265,264,1,0,0,0,266,41,1,0,0,0,267,268,3,44,22,0,268,43,1,
|
||||
0,0,0,269,270,7,1,0,0,270,45,1,0,0,0,271,282,3,40,20,0,272,273,5,34,0,
|
||||
0,273,275,5,10,0,0,274,276,3,50,25,0,275,274,1,0,0,0,275,276,1,0,0,0,
|
||||
276,277,1,0,0,0,277,282,5,11,0,0,278,279,3,48,24,0,279,280,3,46,23,0,
|
||||
280,282,1,0,0,0,281,271,1,0,0,0,281,272,1,0,0,0,281,278,1,0,0,0,282,47,
|
||||
1,0,0,0,283,284,7,2,0,0,284,49,1,0,0,0,285,290,3,52,26,0,286,287,5,2,
|
||||
0,0,287,289,3,52,26,0,288,286,1,0,0,0,289,292,1,0,0,0,290,288,1,0,0,0,
|
||||
290,291,1,0,0,0,291,51,1,0,0,0,292,290,1,0,0,0,293,296,3,34,17,0,294,
|
||||
296,5,41,0,0,295,293,1,0,0,0,295,294,1,0,0,0,296,53,1,0,0,0,297,298,6,
|
||||
27,-1,0,298,299,3,46,23,0,299,305,1,0,0,0,300,301,10,1,0,0,301,302,7,
|
||||
3,0,0,302,304,3,46,23,0,303,300,1,0,0,0,304,307,1,0,0,0,305,303,1,0,0,
|
||||
0,305,306,1,0,0,0,306,55,1,0,0,0,307,305,1,0,0,0,308,309,6,28,-1,0,309,
|
||||
310,3,54,27,0,310,316,1,0,0,0,311,312,10,1,0,0,312,313,7,4,0,0,313,315,
|
||||
3,54,27,0,314,311,1,0,0,0,315,318,1,0,0,0,316,314,1,0,0,0,316,317,1,0,
|
||||
0,0,317,57,1,0,0,0,318,316,1,0,0,0,319,320,6,29,-1,0,320,321,3,56,28,
|
||||
0,321,327,1,0,0,0,322,323,10,1,0,0,323,324,7,5,0,0,324,326,3,56,28,0,
|
||||
325,322,1,0,0,0,326,329,1,0,0,0,327,325,1,0,0,0,327,328,1,0,0,0,328,59,
|
||||
1,0,0,0,329,327,1,0,0,0,330,331,6,30,-1,0,331,332,3,58,29,0,332,338,1,
|
||||
0,0,0,333,334,10,1,0,0,334,335,7,6,0,0,335,337,3,58,29,0,336,333,1,0,
|
||||
0,0,337,340,1,0,0,0,338,336,1,0,0,0,338,339,1,0,0,0,339,61,1,0,0,0,340,
|
||||
338,1,0,0,0,341,346,3,60,30,0,342,343,5,31,0,0,343,345,3,60,30,0,344,
|
||||
342,1,0,0,0,345,348,1,0,0,0,346,344,1,0,0,0,346,347,1,0,0,0,347,63,1,
|
||||
0,0,0,348,346,1,0,0,0,349,354,3,62,31,0,350,351,5,32,0,0,351,353,3,62,
|
||||
31,0,352,350,1,0,0,0,353,356,1,0,0,0,354,352,1,0,0,0,354,355,1,0,0,0,
|
||||
355,65,1,0,0,0,356,354,1,0,0,0,357,358,3,56,28,0,358,67,1,0,0,0,36,72,
|
||||
74,78,87,101,114,117,120,128,140,145,154,157,160,166,178,191,194,200,
|
||||
207,215,226,240,243,256,265,275,281,290,295,305,316,327,338,346,354
|
||||
};
|
||||
staticData->serializedATN = antlr4::atn::SerializedATNView(serializedATNSegment, sizeof(serializedATNSegment) / sizeof(serializedATNSegment[0]));
|
||||
|
||||
@ -2050,7 +2048,7 @@ SysyParser::CondContext* SysyParser::cond() {
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(247);
|
||||
lOrExp(0);
|
||||
lOrExp();
|
||||
|
||||
}
|
||||
catch (RecognitionException &e) {
|
||||
@ -3124,16 +3122,20 @@ SysyParser::LAndExpContext::LAndExpContext(ParserRuleContext *parent, size_t inv
|
||||
: ParserRuleContext(parent, invokingState) {
|
||||
}
|
||||
|
||||
SysyParser::EqExpContext* SysyParser::LAndExpContext::eqExp() {
|
||||
return getRuleContext<SysyParser::EqExpContext>(0);
|
||||
std::vector<SysyParser::EqExpContext *> SysyParser::LAndExpContext::eqExp() {
|
||||
return getRuleContexts<SysyParser::EqExpContext>();
|
||||
}
|
||||
|
||||
SysyParser::LAndExpContext* SysyParser::LAndExpContext::lAndExp() {
|
||||
return getRuleContext<SysyParser::LAndExpContext>(0);
|
||||
SysyParser::EqExpContext* SysyParser::LAndExpContext::eqExp(size_t i) {
|
||||
return getRuleContext<SysyParser::EqExpContext>(i);
|
||||
}
|
||||
|
||||
tree::TerminalNode* SysyParser::LAndExpContext::AND() {
|
||||
return getToken(SysyParser::AND, 0);
|
||||
std::vector<tree::TerminalNode *> SysyParser::LAndExpContext::AND() {
|
||||
return getTokens(SysyParser::AND);
|
||||
}
|
||||
|
||||
tree::TerminalNode* SysyParser::LAndExpContext::AND(size_t i) {
|
||||
return getToken(SysyParser::AND, i);
|
||||
}
|
||||
|
||||
|
||||
@ -3149,63 +3151,42 @@ std::any SysyParser::LAndExpContext::accept(tree::ParseTreeVisitor *visitor) {
|
||||
return visitor->visitChildren(this);
|
||||
}
|
||||
|
||||
|
||||
SysyParser::LAndExpContext* SysyParser::lAndExp() {
|
||||
return lAndExp(0);
|
||||
}
|
||||
|
||||
SysyParser::LAndExpContext* SysyParser::lAndExp(int precedence) {
|
||||
ParserRuleContext *parentContext = _ctx;
|
||||
size_t parentState = getState();
|
||||
SysyParser::LAndExpContext *_localctx = _tracker.createInstance<LAndExpContext>(_ctx, parentState);
|
||||
SysyParser::LAndExpContext *previousContext = _localctx;
|
||||
(void)previousContext; // Silence compiler, in case the context is not used by generated code.
|
||||
size_t startState = 62;
|
||||
enterRecursionRule(_localctx, 62, SysyParser::RuleLAndExp, precedence);
|
||||
|
||||
|
||||
LAndExpContext *_localctx = _tracker.createInstance<LAndExpContext>(_ctx, getState());
|
||||
enterRule(_localctx, 62, SysyParser::RuleLAndExp);
|
||||
size_t _la = 0;
|
||||
|
||||
#if __cplusplus > 201703L
|
||||
auto onExit = finally([=, this] {
|
||||
#else
|
||||
auto onExit = finally([=] {
|
||||
#endif
|
||||
unrollRecursionContexts(parentContext);
|
||||
exitRule();
|
||||
});
|
||||
try {
|
||||
size_t alt;
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(342);
|
||||
setState(341);
|
||||
eqExp(0);
|
||||
_ctx->stop = _input->LT(-1);
|
||||
setState(349);
|
||||
setState(346);
|
||||
_errHandler->sync(this);
|
||||
alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 34, _ctx);
|
||||
while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) {
|
||||
if (alt == 1) {
|
||||
if (!_parseListeners.empty())
|
||||
triggerExitRuleEvent();
|
||||
previousContext = _localctx;
|
||||
_localctx = _tracker.createInstance<LAndExpContext>(parentContext, parentState);
|
||||
pushNewRecursionContext(_localctx, startState, RuleLAndExp);
|
||||
setState(344);
|
||||
|
||||
if (!(precpred(_ctx, 1))) throw FailedPredicateException(this, "precpred(_ctx, 1)");
|
||||
setState(345);
|
||||
match(SysyParser::AND);
|
||||
setState(346);
|
||||
eqExp(0);
|
||||
}
|
||||
setState(351);
|
||||
_la = _input->LA(1);
|
||||
while (_la == SysyParser::AND) {
|
||||
setState(342);
|
||||
match(SysyParser::AND);
|
||||
setState(343);
|
||||
eqExp(0);
|
||||
setState(348);
|
||||
_errHandler->sync(this);
|
||||
alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 34, _ctx);
|
||||
_la = _input->LA(1);
|
||||
}
|
||||
|
||||
}
|
||||
catch (RecognitionException &e) {
|
||||
_errHandler->reportError(this, e);
|
||||
_localctx->exception = std::current_exception();
|
||||
_errHandler->recover(this, _localctx->exception);
|
||||
}
|
||||
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
@ -3215,16 +3196,20 @@ SysyParser::LOrExpContext::LOrExpContext(ParserRuleContext *parent, size_t invok
|
||||
: ParserRuleContext(parent, invokingState) {
|
||||
}
|
||||
|
||||
SysyParser::LAndExpContext* SysyParser::LOrExpContext::lAndExp() {
|
||||
return getRuleContext<SysyParser::LAndExpContext>(0);
|
||||
std::vector<SysyParser::LAndExpContext *> SysyParser::LOrExpContext::lAndExp() {
|
||||
return getRuleContexts<SysyParser::LAndExpContext>();
|
||||
}
|
||||
|
||||
SysyParser::LOrExpContext* SysyParser::LOrExpContext::lOrExp() {
|
||||
return getRuleContext<SysyParser::LOrExpContext>(0);
|
||||
SysyParser::LAndExpContext* SysyParser::LOrExpContext::lAndExp(size_t i) {
|
||||
return getRuleContext<SysyParser::LAndExpContext>(i);
|
||||
}
|
||||
|
||||
tree::TerminalNode* SysyParser::LOrExpContext::OR() {
|
||||
return getToken(SysyParser::OR, 0);
|
||||
std::vector<tree::TerminalNode *> SysyParser::LOrExpContext::OR() {
|
||||
return getTokens(SysyParser::OR);
|
||||
}
|
||||
|
||||
tree::TerminalNode* SysyParser::LOrExpContext::OR(size_t i) {
|
||||
return getToken(SysyParser::OR, i);
|
||||
}
|
||||
|
||||
|
||||
@ -3240,63 +3225,42 @@ std::any SysyParser::LOrExpContext::accept(tree::ParseTreeVisitor *visitor) {
|
||||
return visitor->visitChildren(this);
|
||||
}
|
||||
|
||||
|
||||
SysyParser::LOrExpContext* SysyParser::lOrExp() {
|
||||
return lOrExp(0);
|
||||
}
|
||||
|
||||
SysyParser::LOrExpContext* SysyParser::lOrExp(int precedence) {
|
||||
ParserRuleContext *parentContext = _ctx;
|
||||
size_t parentState = getState();
|
||||
SysyParser::LOrExpContext *_localctx = _tracker.createInstance<LOrExpContext>(_ctx, parentState);
|
||||
SysyParser::LOrExpContext *previousContext = _localctx;
|
||||
(void)previousContext; // Silence compiler, in case the context is not used by generated code.
|
||||
size_t startState = 64;
|
||||
enterRecursionRule(_localctx, 64, SysyParser::RuleLOrExp, precedence);
|
||||
|
||||
|
||||
LOrExpContext *_localctx = _tracker.createInstance<LOrExpContext>(_ctx, getState());
|
||||
enterRule(_localctx, 64, SysyParser::RuleLOrExp);
|
||||
size_t _la = 0;
|
||||
|
||||
#if __cplusplus > 201703L
|
||||
auto onExit = finally([=, this] {
|
||||
#else
|
||||
auto onExit = finally([=] {
|
||||
#endif
|
||||
unrollRecursionContexts(parentContext);
|
||||
exitRule();
|
||||
});
|
||||
try {
|
||||
size_t alt;
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(353);
|
||||
lAndExp(0);
|
||||
_ctx->stop = _input->LT(-1);
|
||||
setState(360);
|
||||
setState(349);
|
||||
lAndExp();
|
||||
setState(354);
|
||||
_errHandler->sync(this);
|
||||
alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 35, _ctx);
|
||||
while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER) {
|
||||
if (alt == 1) {
|
||||
if (!_parseListeners.empty())
|
||||
triggerExitRuleEvent();
|
||||
previousContext = _localctx;
|
||||
_localctx = _tracker.createInstance<LOrExpContext>(parentContext, parentState);
|
||||
pushNewRecursionContext(_localctx, startState, RuleLOrExp);
|
||||
setState(355);
|
||||
|
||||
if (!(precpred(_ctx, 1))) throw FailedPredicateException(this, "precpred(_ctx, 1)");
|
||||
setState(356);
|
||||
match(SysyParser::OR);
|
||||
setState(357);
|
||||
lAndExp(0);
|
||||
}
|
||||
setState(362);
|
||||
_la = _input->LA(1);
|
||||
while (_la == SysyParser::OR) {
|
||||
setState(350);
|
||||
match(SysyParser::OR);
|
||||
setState(351);
|
||||
lAndExp();
|
||||
setState(356);
|
||||
_errHandler->sync(this);
|
||||
alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 35, _ctx);
|
||||
_la = _input->LA(1);
|
||||
}
|
||||
|
||||
}
|
||||
catch (RecognitionException &e) {
|
||||
_errHandler->reportError(this, e);
|
||||
_localctx->exception = std::current_exception();
|
||||
_errHandler->recover(this, _localctx->exception);
|
||||
}
|
||||
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
@ -3336,7 +3300,7 @@ SysyParser::ConstExpContext* SysyParser::constExp() {
|
||||
});
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(363);
|
||||
setState(357);
|
||||
addExp(0);
|
||||
|
||||
}
|
||||
@ -3355,8 +3319,6 @@ bool SysyParser::sempred(RuleContext *context, size_t ruleIndex, size_t predicat
|
||||
case 28: return addExpSempred(antlrcpp::downCast<AddExpContext *>(context), predicateIndex);
|
||||
case 29: return relExpSempred(antlrcpp::downCast<RelExpContext *>(context), predicateIndex);
|
||||
case 30: return eqExpSempred(antlrcpp::downCast<EqExpContext *>(context), predicateIndex);
|
||||
case 31: return lAndExpSempred(antlrcpp::downCast<LAndExpContext *>(context), predicateIndex);
|
||||
case 32: return lOrExpSempred(antlrcpp::downCast<LOrExpContext *>(context), predicateIndex);
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -3404,26 +3366,6 @@ bool SysyParser::eqExpSempred(EqExpContext *_localctx, size_t predicateIndex) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SysyParser::lAndExpSempred(LAndExpContext *_localctx, size_t predicateIndex) {
|
||||
switch (predicateIndex) {
|
||||
case 4: return precpred(_ctx, 1);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SysyParser::lOrExpSempred(LOrExpContext *_localctx, size_t predicateIndex) {
|
||||
switch (predicateIndex) {
|
||||
case 5: return precpred(_ctx, 1);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SysyParser::initialize() {
|
||||
::antlr4::internal::call_once(sysyParserOnceFlag, sysyParserInitialize);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user