| 1 | # Generated from parser/CMOD.g4 by ANTLR 4.13.2
|
|---|
| 2 | # encoding: utf-8
|
|---|
| 3 | from antlr4 import *
|
|---|
| 4 | from io import StringIO
|
|---|
| 5 | import sys
|
|---|
| 6 | if sys.version_info[1] > 5:
|
|---|
| 7 | from typing import TextIO
|
|---|
| 8 | else:
|
|---|
| 9 | from typing.io import TextIO
|
|---|
| 10 |
|
|---|
| 11 | def serializedATN():
|
|---|
| 12 | return [
|
|---|
| 13 | 4,1,28,154,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,
|
|---|
| 14 | 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,
|
|---|
| 15 | 1,0,1,0,1,0,1,1,1,1,5,1,34,8,1,10,1,12,1,37,9,1,1,1,5,1,40,8,1,10,
|
|---|
| 16 | 1,12,1,43,9,1,1,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,5,3,53,8,3,10,3,12,
|
|---|
| 17 | 3,56,9,3,3,3,58,8,3,1,3,1,3,1,4,3,4,63,8,4,1,4,1,4,3,4,67,8,4,1,
|
|---|
| 18 | 4,1,4,3,4,71,8,4,1,4,1,4,3,4,75,8,4,1,5,1,5,1,5,1,5,3,5,81,8,5,1,
|
|---|
| 19 | 5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,3,6,95,8,6,1,7,3,7,
|
|---|
| 20 | 98,8,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,8,5,8,108,8,8,10,8,12,8,111,
|
|---|
| 21 | 9,8,1,9,1,9,5,9,115,8,9,10,9,12,9,118,9,9,1,9,1,9,1,10,1,10,1,10,
|
|---|
| 22 | 1,10,1,10,1,10,1,10,1,10,1,10,3,10,131,8,10,1,11,1,11,1,11,1,11,
|
|---|
| 23 | 3,11,137,8,11,1,11,1,11,1,12,1,12,1,12,5,12,144,8,12,10,12,12,12,
|
|---|
| 24 | 147,9,12,1,13,1,13,1,13,1,13,1,13,1,13,0,0,14,0,2,4,6,8,10,12,14,
|
|---|
| 25 | 16,18,20,22,24,26,0,0,164,0,28,1,0,0,0,2,31,1,0,0,0,4,44,1,0,0,0,
|
|---|
| 26 | 6,47,1,0,0,0,8,74,1,0,0,0,10,76,1,0,0,0,12,94,1,0,0,0,14,97,1,0,
|
|---|
| 27 | 0,0,16,101,1,0,0,0,18,112,1,0,0,0,20,130,1,0,0,0,22,132,1,0,0,0,
|
|---|
| 28 | 24,140,1,0,0,0,26,148,1,0,0,0,28,29,3,2,1,0,29,30,5,0,0,1,30,1,1,
|
|---|
| 29 | 0,0,0,31,35,3,4,2,0,32,34,3,6,3,0,33,32,1,0,0,0,34,37,1,0,0,0,35,
|
|---|
| 30 | 33,1,0,0,0,35,36,1,0,0,0,36,41,1,0,0,0,37,35,1,0,0,0,38,40,3,8,4,
|
|---|
| 31 | 0,39,38,1,0,0,0,40,43,1,0,0,0,41,39,1,0,0,0,41,42,1,0,0,0,42,3,1,
|
|---|
| 32 | 0,0,0,43,41,1,0,0,0,44,45,5,1,0,0,45,46,5,2,0,0,46,5,1,0,0,0,47,
|
|---|
| 33 | 57,5,3,0,0,48,58,5,24,0,0,49,54,5,23,0,0,50,51,5,4,0,0,51,53,5,23,
|
|---|
| 34 | 0,0,52,50,1,0,0,0,53,56,1,0,0,0,54,52,1,0,0,0,54,55,1,0,0,0,55,58,
|
|---|
| 35 | 1,0,0,0,56,54,1,0,0,0,57,48,1,0,0,0,57,49,1,0,0,0,58,59,1,0,0,0,
|
|---|
| 36 | 59,60,5,2,0,0,60,7,1,0,0,0,61,63,5,5,0,0,62,61,1,0,0,0,62,63,1,0,
|
|---|
| 37 | 0,0,63,64,1,0,0,0,64,75,3,10,5,0,65,67,5,5,0,0,66,65,1,0,0,0,66,
|
|---|
| 38 | 67,1,0,0,0,67,68,1,0,0,0,68,75,3,22,11,0,69,71,5,5,0,0,70,69,1,0,
|
|---|
| 39 | 0,0,70,71,1,0,0,0,71,72,1,0,0,0,72,75,3,26,13,0,73,75,5,2,0,0,74,
|
|---|
| 40 | 62,1,0,0,0,74,66,1,0,0,0,74,70,1,0,0,0,74,73,1,0,0,0,75,9,1,0,0,
|
|---|
| 41 | 0,76,77,3,12,6,0,77,78,3,14,7,0,78,80,5,6,0,0,79,81,3,16,8,0,80,
|
|---|
| 42 | 79,1,0,0,0,80,81,1,0,0,0,81,82,1,0,0,0,82,83,5,7,0,0,83,84,3,18,
|
|---|
| 43 | 9,0,84,11,1,0,0,0,85,95,5,8,0,0,86,95,5,9,0,0,87,95,5,10,0,0,88,
|
|---|
| 44 | 95,5,11,0,0,89,95,5,12,0,0,90,95,5,13,0,0,91,95,5,14,0,0,92,93,5,
|
|---|
| 45 | 15,0,0,93,95,5,23,0,0,94,85,1,0,0,0,94,86,1,0,0,0,94,87,1,0,0,0,
|
|---|
| 46 | 94,88,1,0,0,0,94,89,1,0,0,0,94,90,1,0,0,0,94,91,1,0,0,0,94,92,1,
|
|---|
| 47 | 0,0,0,95,13,1,0,0,0,96,98,5,16,0,0,97,96,1,0,0,0,97,98,1,0,0,0,98,
|
|---|
| 48 | 99,1,0,0,0,99,100,5,23,0,0,100,15,1,0,0,0,101,102,3,12,6,0,102,109,
|
|---|
| 49 | 3,14,7,0,103,104,5,17,0,0,104,105,3,12,6,0,105,106,3,14,7,0,106,
|
|---|
| 50 | 108,1,0,0,0,107,103,1,0,0,0,108,111,1,0,0,0,109,107,1,0,0,0,109,
|
|---|
| 51 | 110,1,0,0,0,110,17,1,0,0,0,111,109,1,0,0,0,112,116,5,18,0,0,113,
|
|---|
| 52 | 115,3,20,10,0,114,113,1,0,0,0,115,118,1,0,0,0,116,114,1,0,0,0,116,
|
|---|
| 53 | 117,1,0,0,0,117,119,1,0,0,0,118,116,1,0,0,0,119,120,5,19,0,0,120,
|
|---|
| 54 | 19,1,0,0,0,121,122,5,23,0,0,122,131,5,2,0,0,123,124,5,20,0,0,124,
|
|---|
| 55 | 125,5,23,0,0,125,131,5,2,0,0,126,127,5,20,0,0,127,128,5,16,0,0,128,
|
|---|
| 56 | 129,5,23,0,0,129,131,5,2,0,0,130,121,1,0,0,0,130,123,1,0,0,0,130,
|
|---|
| 57 | 126,1,0,0,0,131,21,1,0,0,0,132,133,3,12,6,0,133,136,3,14,7,0,134,
|
|---|
| 58 | 135,5,21,0,0,135,137,3,24,12,0,136,134,1,0,0,0,136,137,1,0,0,0,137,
|
|---|
| 59 | 138,1,0,0,0,138,139,5,2,0,0,139,23,1,0,0,0,140,145,5,23,0,0,141,
|
|---|
| 60 | 142,5,22,0,0,142,144,5,23,0,0,143,141,1,0,0,0,144,147,1,0,0,0,145,
|
|---|
| 61 | 143,1,0,0,0,145,146,1,0,0,0,146,25,1,0,0,0,147,145,1,0,0,0,148,149,
|
|---|
| 62 | 5,15,0,0,149,150,5,23,0,0,150,151,3,18,9,0,151,152,5,2,0,0,152,27,
|
|---|
| 63 | 1,0,0,0,16,35,41,54,57,62,66,70,74,80,94,97,109,116,130,136,145
|
|---|
| 64 | ]
|
|---|
| 65 |
|
|---|
| 66 | class CMODParser ( Parser ):
|
|---|
| 67 |
|
|---|
| 68 | grammarFileName = "CMOD.g4"
|
|---|
| 69 |
|
|---|
| 70 | atn = ATNDeserializer().deserialize(serializedATN())
|
|---|
| 71 |
|
|---|
| 72 | decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
|
|---|
| 73 |
|
|---|
| 74 | sharedContextCache = PredictionContextCache()
|
|---|
| 75 |
|
|---|
| 76 | literalNames = [ "<INVALID>", "'module'", "';'", "'import'", "'/'",
|
|---|
| 77 | "'export'", "'('", "')'", "'void'", "'char'", "'short'",
|
|---|
| 78 | "'int'", "'long'", "'float'", "'double'", "'struct'",
|
|---|
| 79 | "'*'", "','", "'{'", "'}'", "'type'", "'='", "'+'" ]
|
|---|
| 80 |
|
|---|
| 81 | symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
|---|
| 82 | "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
|---|
| 83 | "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
|---|
| 84 | "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
|---|
| 85 | "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
|---|
| 86 | "<INVALID>", "<INVALID>", "<INVALID>", "Identifier",
|
|---|
| 87 | "StringLiteral", "Whitespace", "Newline", "BlockComment",
|
|---|
| 88 | "LineComment" ]
|
|---|
| 89 |
|
|---|
| 90 | RULE_compilationUnit = 0
|
|---|
| 91 | RULE_translationUnit = 1
|
|---|
| 92 | RULE_moduleDeclaration = 2
|
|---|
| 93 | RULE_importDeclaration = 3
|
|---|
| 94 | RULE_externalDeclaration = 4
|
|---|
| 95 | RULE_limitedFunctionDefinition = 5
|
|---|
| 96 | RULE_limitedTypeSpecifier = 6
|
|---|
| 97 | RULE_limitedDeclarator = 7
|
|---|
| 98 | RULE_limitedParameterList = 8
|
|---|
| 99 | RULE_limitedCompoundStatement = 9
|
|---|
| 100 | RULE_limitedStatement = 10
|
|---|
| 101 | RULE_limitedGlobal = 11
|
|---|
| 102 | RULE_limitedInitializer = 12
|
|---|
| 103 | RULE_limitedStruct = 13
|
|---|
| 104 |
|
|---|
| 105 | ruleNames = [ "compilationUnit", "translationUnit", "moduleDeclaration",
|
|---|
| 106 | "importDeclaration", "externalDeclaration", "limitedFunctionDefinition",
|
|---|
| 107 | "limitedTypeSpecifier", "limitedDeclarator", "limitedParameterList",
|
|---|
| 108 | "limitedCompoundStatement", "limitedStatement", "limitedGlobal",
|
|---|
| 109 | "limitedInitializer", "limitedStruct" ]
|
|---|
| 110 |
|
|---|
| 111 | EOF = Token.EOF
|
|---|
| 112 | T__0=1
|
|---|
| 113 | T__1=2
|
|---|
| 114 | T__2=3
|
|---|
| 115 | T__3=4
|
|---|
| 116 | T__4=5
|
|---|
| 117 | T__5=6
|
|---|
| 118 | T__6=7
|
|---|
| 119 | T__7=8
|
|---|
| 120 | T__8=9
|
|---|
| 121 | T__9=10
|
|---|
| 122 | T__10=11
|
|---|
| 123 | T__11=12
|
|---|
| 124 | T__12=13
|
|---|
| 125 | T__13=14
|
|---|
| 126 | T__14=15
|
|---|
| 127 | T__15=16
|
|---|
| 128 | T__16=17
|
|---|
| 129 | T__17=18
|
|---|
| 130 | T__18=19
|
|---|
| 131 | T__19=20
|
|---|
| 132 | T__20=21
|
|---|
| 133 | T__21=22
|
|---|
| 134 | Identifier=23
|
|---|
| 135 | StringLiteral=24
|
|---|
| 136 | Whitespace=25
|
|---|
| 137 | Newline=26
|
|---|
| 138 | BlockComment=27
|
|---|
| 139 | LineComment=28
|
|---|
| 140 |
|
|---|
| 141 | def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
|
|---|
| 142 | super().__init__(input, output)
|
|---|
| 143 | self.checkVersion("4.13.2")
|
|---|
| 144 | self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
|
|---|
| 145 | self._predicates = None
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 | class CompilationUnitContext(ParserRuleContext):
|
|---|
| 151 | __slots__ = 'parser'
|
|---|
| 152 |
|
|---|
| 153 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 154 | super().__init__(parent, invokingState)
|
|---|
| 155 | self.parser = parser
|
|---|
| 156 |
|
|---|
| 157 | def translationUnit(self):
|
|---|
| 158 | return self.getTypedRuleContext(CMODParser.TranslationUnitContext,0)
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 | def EOF(self):
|
|---|
| 162 | return self.getToken(CMODParser.EOF, 0)
|
|---|
| 163 |
|
|---|
| 164 | def getRuleIndex(self):
|
|---|
| 165 | return CMODParser.RULE_compilationUnit
|
|---|
| 166 |
|
|---|
| 167 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 168 | if hasattr( listener, "enterCompilationUnit" ):
|
|---|
| 169 | listener.enterCompilationUnit(self)
|
|---|
| 170 |
|
|---|
| 171 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 172 | if hasattr( listener, "exitCompilationUnit" ):
|
|---|
| 173 | listener.exitCompilationUnit(self)
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 | def compilationUnit(self):
|
|---|
| 179 |
|
|---|
| 180 | localctx = CMODParser.CompilationUnitContext(self, self._ctx, self.state)
|
|---|
| 181 | self.enterRule(localctx, 0, self.RULE_compilationUnit)
|
|---|
| 182 | try:
|
|---|
| 183 | self.enterOuterAlt(localctx, 1)
|
|---|
| 184 | self.state = 28
|
|---|
| 185 | self.translationUnit()
|
|---|
| 186 | self.state = 29
|
|---|
| 187 | self.match(CMODParser.EOF)
|
|---|
| 188 | except RecognitionException as re:
|
|---|
| 189 | localctx.exception = re
|
|---|
| 190 | self._errHandler.reportError(self, re)
|
|---|
| 191 | self._errHandler.recover(self, re)
|
|---|
| 192 | finally:
|
|---|
| 193 | self.exitRule()
|
|---|
| 194 | return localctx
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | class TranslationUnitContext(ParserRuleContext):
|
|---|
| 198 | __slots__ = 'parser'
|
|---|
| 199 |
|
|---|
| 200 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 201 | super().__init__(parent, invokingState)
|
|---|
| 202 | self.parser = parser
|
|---|
| 203 |
|
|---|
| 204 | def moduleDeclaration(self):
|
|---|
| 205 | return self.getTypedRuleContext(CMODParser.ModuleDeclarationContext,0)
|
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 | def importDeclaration(self, i:int=None):
|
|---|
| 209 | if i is None:
|
|---|
| 210 | return self.getTypedRuleContexts(CMODParser.ImportDeclarationContext)
|
|---|
| 211 | else:
|
|---|
| 212 | return self.getTypedRuleContext(CMODParser.ImportDeclarationContext,i)
|
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 | def externalDeclaration(self, i:int=None):
|
|---|
| 216 | if i is None:
|
|---|
| 217 | return self.getTypedRuleContexts(CMODParser.ExternalDeclarationContext)
|
|---|
| 218 | else:
|
|---|
| 219 | return self.getTypedRuleContext(CMODParser.ExternalDeclarationContext,i)
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 | def getRuleIndex(self):
|
|---|
| 223 | return CMODParser.RULE_translationUnit
|
|---|
| 224 |
|
|---|
| 225 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 226 | if hasattr( listener, "enterTranslationUnit" ):
|
|---|
| 227 | listener.enterTranslationUnit(self)
|
|---|
| 228 |
|
|---|
| 229 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 230 | if hasattr( listener, "exitTranslationUnit" ):
|
|---|
| 231 | listener.exitTranslationUnit(self)
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 | def translationUnit(self):
|
|---|
| 237 |
|
|---|
| 238 | localctx = CMODParser.TranslationUnitContext(self, self._ctx, self.state)
|
|---|
| 239 | self.enterRule(localctx, 2, self.RULE_translationUnit)
|
|---|
| 240 | self._la = 0 # Token type
|
|---|
| 241 | try:
|
|---|
| 242 | self.enterOuterAlt(localctx, 1)
|
|---|
| 243 | self.state = 31
|
|---|
| 244 | self.moduleDeclaration()
|
|---|
| 245 | self.state = 35
|
|---|
| 246 | self._errHandler.sync(self)
|
|---|
| 247 | _la = self._input.LA(1)
|
|---|
| 248 | while _la==3:
|
|---|
| 249 | self.state = 32
|
|---|
| 250 | self.importDeclaration()
|
|---|
| 251 | self.state = 37
|
|---|
| 252 | self._errHandler.sync(self)
|
|---|
| 253 | _la = self._input.LA(1)
|
|---|
| 254 |
|
|---|
| 255 | self.state = 41
|
|---|
| 256 | self._errHandler.sync(self)
|
|---|
| 257 | _la = self._input.LA(1)
|
|---|
| 258 | while (((_la) & ~0x3f) == 0 and ((1 << _la) & 65316) != 0):
|
|---|
| 259 | self.state = 38
|
|---|
| 260 | self.externalDeclaration()
|
|---|
| 261 | self.state = 43
|
|---|
| 262 | self._errHandler.sync(self)
|
|---|
| 263 | _la = self._input.LA(1)
|
|---|
| 264 |
|
|---|
| 265 | except RecognitionException as re:
|
|---|
| 266 | localctx.exception = re
|
|---|
| 267 | self._errHandler.reportError(self, re)
|
|---|
| 268 | self._errHandler.recover(self, re)
|
|---|
| 269 | finally:
|
|---|
| 270 | self.exitRule()
|
|---|
| 271 | return localctx
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 | class ModuleDeclarationContext(ParserRuleContext):
|
|---|
| 275 | __slots__ = 'parser'
|
|---|
| 276 |
|
|---|
| 277 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 278 | super().__init__(parent, invokingState)
|
|---|
| 279 | self.parser = parser
|
|---|
| 280 |
|
|---|
| 281 |
|
|---|
| 282 | def getRuleIndex(self):
|
|---|
| 283 | return CMODParser.RULE_moduleDeclaration
|
|---|
| 284 |
|
|---|
| 285 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 286 | if hasattr( listener, "enterModuleDeclaration" ):
|
|---|
| 287 | listener.enterModuleDeclaration(self)
|
|---|
| 288 |
|
|---|
| 289 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 290 | if hasattr( listener, "exitModuleDeclaration" ):
|
|---|
| 291 | listener.exitModuleDeclaration(self)
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 |
|
|---|
| 296 | def moduleDeclaration(self):
|
|---|
| 297 |
|
|---|
| 298 | localctx = CMODParser.ModuleDeclarationContext(self, self._ctx, self.state)
|
|---|
| 299 | self.enterRule(localctx, 4, self.RULE_moduleDeclaration)
|
|---|
| 300 | try:
|
|---|
| 301 | self.enterOuterAlt(localctx, 1)
|
|---|
| 302 | self.state = 44
|
|---|
| 303 | self.match(CMODParser.T__0)
|
|---|
| 304 | self.state = 45
|
|---|
| 305 | self.match(CMODParser.T__1)
|
|---|
| 306 | except RecognitionException as re:
|
|---|
| 307 | localctx.exception = re
|
|---|
| 308 | self._errHandler.reportError(self, re)
|
|---|
| 309 | self._errHandler.recover(self, re)
|
|---|
| 310 | finally:
|
|---|
| 311 | self.exitRule()
|
|---|
| 312 | return localctx
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 | class ImportDeclarationContext(ParserRuleContext):
|
|---|
| 316 | __slots__ = 'parser'
|
|---|
| 317 |
|
|---|
| 318 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 319 | super().__init__(parent, invokingState)
|
|---|
| 320 | self.parser = parser
|
|---|
| 321 |
|
|---|
| 322 | def StringLiteral(self):
|
|---|
| 323 | return self.getToken(CMODParser.StringLiteral, 0)
|
|---|
| 324 |
|
|---|
| 325 | def Identifier(self, i:int=None):
|
|---|
| 326 | if i is None:
|
|---|
| 327 | return self.getTokens(CMODParser.Identifier)
|
|---|
| 328 | else:
|
|---|
| 329 | return self.getToken(CMODParser.Identifier, i)
|
|---|
| 330 |
|
|---|
| 331 | def getRuleIndex(self):
|
|---|
| 332 | return CMODParser.RULE_importDeclaration
|
|---|
| 333 |
|
|---|
| 334 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 335 | if hasattr( listener, "enterImportDeclaration" ):
|
|---|
| 336 | listener.enterImportDeclaration(self)
|
|---|
| 337 |
|
|---|
| 338 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 339 | if hasattr( listener, "exitImportDeclaration" ):
|
|---|
| 340 | listener.exitImportDeclaration(self)
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 | def importDeclaration(self):
|
|---|
| 346 |
|
|---|
| 347 | localctx = CMODParser.ImportDeclarationContext(self, self._ctx, self.state)
|
|---|
| 348 | self.enterRule(localctx, 6, self.RULE_importDeclaration)
|
|---|
| 349 | self._la = 0 # Token type
|
|---|
| 350 | try:
|
|---|
| 351 | self.enterOuterAlt(localctx, 1)
|
|---|
| 352 | self.state = 47
|
|---|
| 353 | self.match(CMODParser.T__2)
|
|---|
| 354 | self.state = 57
|
|---|
| 355 | self._errHandler.sync(self)
|
|---|
| 356 | token = self._input.LA(1)
|
|---|
| 357 | if token in [24]:
|
|---|
| 358 | self.state = 48
|
|---|
| 359 | self.match(CMODParser.StringLiteral)
|
|---|
| 360 | pass
|
|---|
| 361 | elif token in [23]:
|
|---|
| 362 | self.state = 49
|
|---|
| 363 | self.match(CMODParser.Identifier)
|
|---|
| 364 | self.state = 54
|
|---|
| 365 | self._errHandler.sync(self)
|
|---|
| 366 | _la = self._input.LA(1)
|
|---|
| 367 | while _la==4:
|
|---|
| 368 | self.state = 50
|
|---|
| 369 | self.match(CMODParser.T__3)
|
|---|
| 370 | self.state = 51
|
|---|
| 371 | self.match(CMODParser.Identifier)
|
|---|
| 372 | self.state = 56
|
|---|
| 373 | self._errHandler.sync(self)
|
|---|
| 374 | _la = self._input.LA(1)
|
|---|
| 375 |
|
|---|
| 376 | pass
|
|---|
| 377 | else:
|
|---|
| 378 | raise NoViableAltException(self)
|
|---|
| 379 |
|
|---|
| 380 | self.state = 59
|
|---|
| 381 | self.match(CMODParser.T__1)
|
|---|
| 382 | except RecognitionException as re:
|
|---|
| 383 | localctx.exception = re
|
|---|
| 384 | self._errHandler.reportError(self, re)
|
|---|
| 385 | self._errHandler.recover(self, re)
|
|---|
| 386 | finally:
|
|---|
| 387 | self.exitRule()
|
|---|
| 388 | return localctx
|
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 | class ExternalDeclarationContext(ParserRuleContext):
|
|---|
| 392 | __slots__ = 'parser'
|
|---|
| 393 |
|
|---|
| 394 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 395 | super().__init__(parent, invokingState)
|
|---|
| 396 | self.parser = parser
|
|---|
| 397 |
|
|---|
| 398 | def limitedFunctionDefinition(self):
|
|---|
| 399 | return self.getTypedRuleContext(CMODParser.LimitedFunctionDefinitionContext,0)
|
|---|
| 400 |
|
|---|
| 401 |
|
|---|
| 402 | def limitedGlobal(self):
|
|---|
| 403 | return self.getTypedRuleContext(CMODParser.LimitedGlobalContext,0)
|
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 | def limitedStruct(self):
|
|---|
| 407 | return self.getTypedRuleContext(CMODParser.LimitedStructContext,0)
|
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 | def getRuleIndex(self):
|
|---|
| 411 | return CMODParser.RULE_externalDeclaration
|
|---|
| 412 |
|
|---|
| 413 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 414 | if hasattr( listener, "enterExternalDeclaration" ):
|
|---|
| 415 | listener.enterExternalDeclaration(self)
|
|---|
| 416 |
|
|---|
| 417 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 418 | if hasattr( listener, "exitExternalDeclaration" ):
|
|---|
| 419 | listener.exitExternalDeclaration(self)
|
|---|
| 420 |
|
|---|
| 421 |
|
|---|
| 422 |
|
|---|
| 423 |
|
|---|
| 424 | def externalDeclaration(self):
|
|---|
| 425 |
|
|---|
| 426 | localctx = CMODParser.ExternalDeclarationContext(self, self._ctx, self.state)
|
|---|
| 427 | self.enterRule(localctx, 8, self.RULE_externalDeclaration)
|
|---|
| 428 | self._la = 0 # Token type
|
|---|
| 429 | try:
|
|---|
| 430 | self.state = 74
|
|---|
| 431 | self._errHandler.sync(self)
|
|---|
| 432 | la_ = self._interp.adaptivePredict(self._input,7,self._ctx)
|
|---|
| 433 | if la_ == 1:
|
|---|
| 434 | self.enterOuterAlt(localctx, 1)
|
|---|
| 435 | self.state = 62
|
|---|
| 436 | self._errHandler.sync(self)
|
|---|
| 437 | _la = self._input.LA(1)
|
|---|
| 438 | if _la==5:
|
|---|
| 439 | self.state = 61
|
|---|
| 440 | self.match(CMODParser.T__4)
|
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 | self.state = 64
|
|---|
| 444 | self.limitedFunctionDefinition()
|
|---|
| 445 | pass
|
|---|
| 446 |
|
|---|
| 447 | elif la_ == 2:
|
|---|
| 448 | self.enterOuterAlt(localctx, 2)
|
|---|
| 449 | self.state = 66
|
|---|
| 450 | self._errHandler.sync(self)
|
|---|
| 451 | _la = self._input.LA(1)
|
|---|
| 452 | if _la==5:
|
|---|
| 453 | self.state = 65
|
|---|
| 454 | self.match(CMODParser.T__4)
|
|---|
| 455 |
|
|---|
| 456 |
|
|---|
| 457 | self.state = 68
|
|---|
| 458 | self.limitedGlobal()
|
|---|
| 459 | pass
|
|---|
| 460 |
|
|---|
| 461 | elif la_ == 3:
|
|---|
| 462 | self.enterOuterAlt(localctx, 3)
|
|---|
| 463 | self.state = 70
|
|---|
| 464 | self._errHandler.sync(self)
|
|---|
| 465 | _la = self._input.LA(1)
|
|---|
| 466 | if _la==5:
|
|---|
| 467 | self.state = 69
|
|---|
| 468 | self.match(CMODParser.T__4)
|
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 | self.state = 72
|
|---|
| 472 | self.limitedStruct()
|
|---|
| 473 | pass
|
|---|
| 474 |
|
|---|
| 475 | elif la_ == 4:
|
|---|
| 476 | self.enterOuterAlt(localctx, 4)
|
|---|
| 477 | self.state = 73
|
|---|
| 478 | self.match(CMODParser.T__1)
|
|---|
| 479 | pass
|
|---|
| 480 |
|
|---|
| 481 |
|
|---|
| 482 | except RecognitionException as re:
|
|---|
| 483 | localctx.exception = re
|
|---|
| 484 | self._errHandler.reportError(self, re)
|
|---|
| 485 | self._errHandler.recover(self, re)
|
|---|
| 486 | finally:
|
|---|
| 487 | self.exitRule()
|
|---|
| 488 | return localctx
|
|---|
| 489 |
|
|---|
| 490 |
|
|---|
| 491 | class LimitedFunctionDefinitionContext(ParserRuleContext):
|
|---|
| 492 | __slots__ = 'parser'
|
|---|
| 493 |
|
|---|
| 494 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 495 | super().__init__(parent, invokingState)
|
|---|
| 496 | self.parser = parser
|
|---|
| 497 |
|
|---|
| 498 | def limitedTypeSpecifier(self):
|
|---|
| 499 | return self.getTypedRuleContext(CMODParser.LimitedTypeSpecifierContext,0)
|
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 | def limitedDeclarator(self):
|
|---|
| 503 | return self.getTypedRuleContext(CMODParser.LimitedDeclaratorContext,0)
|
|---|
| 504 |
|
|---|
| 505 |
|
|---|
| 506 | def limitedCompoundStatement(self):
|
|---|
| 507 | return self.getTypedRuleContext(CMODParser.LimitedCompoundStatementContext,0)
|
|---|
| 508 |
|
|---|
| 509 |
|
|---|
| 510 | def limitedParameterList(self):
|
|---|
| 511 | return self.getTypedRuleContext(CMODParser.LimitedParameterListContext,0)
|
|---|
| 512 |
|
|---|
| 513 |
|
|---|
| 514 | def getRuleIndex(self):
|
|---|
| 515 | return CMODParser.RULE_limitedFunctionDefinition
|
|---|
| 516 |
|
|---|
| 517 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 518 | if hasattr( listener, "enterLimitedFunctionDefinition" ):
|
|---|
| 519 | listener.enterLimitedFunctionDefinition(self)
|
|---|
| 520 |
|
|---|
| 521 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 522 | if hasattr( listener, "exitLimitedFunctionDefinition" ):
|
|---|
| 523 | listener.exitLimitedFunctionDefinition(self)
|
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 |
|
|---|
| 527 |
|
|---|
| 528 | def limitedFunctionDefinition(self):
|
|---|
| 529 |
|
|---|
| 530 | localctx = CMODParser.LimitedFunctionDefinitionContext(self, self._ctx, self.state)
|
|---|
| 531 | self.enterRule(localctx, 10, self.RULE_limitedFunctionDefinition)
|
|---|
| 532 | self._la = 0 # Token type
|
|---|
| 533 | try:
|
|---|
| 534 | self.enterOuterAlt(localctx, 1)
|
|---|
| 535 | self.state = 76
|
|---|
| 536 | self.limitedTypeSpecifier()
|
|---|
| 537 | self.state = 77
|
|---|
| 538 | self.limitedDeclarator()
|
|---|
| 539 | self.state = 78
|
|---|
| 540 | self.match(CMODParser.T__5)
|
|---|
| 541 | self.state = 80
|
|---|
| 542 | self._errHandler.sync(self)
|
|---|
| 543 | _la = self._input.LA(1)
|
|---|
| 544 | if (((_la) & ~0x3f) == 0 and ((1 << _la) & 65280) != 0):
|
|---|
| 545 | self.state = 79
|
|---|
| 546 | self.limitedParameterList()
|
|---|
| 547 |
|
|---|
| 548 |
|
|---|
| 549 | self.state = 82
|
|---|
| 550 | self.match(CMODParser.T__6)
|
|---|
| 551 | self.state = 83
|
|---|
| 552 | self.limitedCompoundStatement()
|
|---|
| 553 | except RecognitionException as re:
|
|---|
| 554 | localctx.exception = re
|
|---|
| 555 | self._errHandler.reportError(self, re)
|
|---|
| 556 | self._errHandler.recover(self, re)
|
|---|
| 557 | finally:
|
|---|
| 558 | self.exitRule()
|
|---|
| 559 | return localctx
|
|---|
| 560 |
|
|---|
| 561 |
|
|---|
| 562 | class LimitedTypeSpecifierContext(ParserRuleContext):
|
|---|
| 563 | __slots__ = 'parser'
|
|---|
| 564 |
|
|---|
| 565 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 566 | super().__init__(parent, invokingState)
|
|---|
| 567 | self.parser = parser
|
|---|
| 568 |
|
|---|
| 569 | def Identifier(self):
|
|---|
| 570 | return self.getToken(CMODParser.Identifier, 0)
|
|---|
| 571 |
|
|---|
| 572 | def getRuleIndex(self):
|
|---|
| 573 | return CMODParser.RULE_limitedTypeSpecifier
|
|---|
| 574 |
|
|---|
| 575 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 576 | if hasattr( listener, "enterLimitedTypeSpecifier" ):
|
|---|
| 577 | listener.enterLimitedTypeSpecifier(self)
|
|---|
| 578 |
|
|---|
| 579 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 580 | if hasattr( listener, "exitLimitedTypeSpecifier" ):
|
|---|
| 581 | listener.exitLimitedTypeSpecifier(self)
|
|---|
| 582 |
|
|---|
| 583 |
|
|---|
| 584 |
|
|---|
| 585 |
|
|---|
| 586 | def limitedTypeSpecifier(self):
|
|---|
| 587 |
|
|---|
| 588 | localctx = CMODParser.LimitedTypeSpecifierContext(self, self._ctx, self.state)
|
|---|
| 589 | self.enterRule(localctx, 12, self.RULE_limitedTypeSpecifier)
|
|---|
| 590 | try:
|
|---|
| 591 | self.state = 94
|
|---|
| 592 | self._errHandler.sync(self)
|
|---|
| 593 | token = self._input.LA(1)
|
|---|
| 594 | if token in [8]:
|
|---|
| 595 | self.enterOuterAlt(localctx, 1)
|
|---|
| 596 | self.state = 85
|
|---|
| 597 | self.match(CMODParser.T__7)
|
|---|
| 598 | pass
|
|---|
| 599 | elif token in [9]:
|
|---|
| 600 | self.enterOuterAlt(localctx, 2)
|
|---|
| 601 | self.state = 86
|
|---|
| 602 | self.match(CMODParser.T__8)
|
|---|
| 603 | pass
|
|---|
| 604 | elif token in [10]:
|
|---|
| 605 | self.enterOuterAlt(localctx, 3)
|
|---|
| 606 | self.state = 87
|
|---|
| 607 | self.match(CMODParser.T__9)
|
|---|
| 608 | pass
|
|---|
| 609 | elif token in [11]:
|
|---|
| 610 | self.enterOuterAlt(localctx, 4)
|
|---|
| 611 | self.state = 88
|
|---|
| 612 | self.match(CMODParser.T__10)
|
|---|
| 613 | pass
|
|---|
| 614 | elif token in [12]:
|
|---|
| 615 | self.enterOuterAlt(localctx, 5)
|
|---|
| 616 | self.state = 89
|
|---|
| 617 | self.match(CMODParser.T__11)
|
|---|
| 618 | pass
|
|---|
| 619 | elif token in [13]:
|
|---|
| 620 | self.enterOuterAlt(localctx, 6)
|
|---|
| 621 | self.state = 90
|
|---|
| 622 | self.match(CMODParser.T__12)
|
|---|
| 623 | pass
|
|---|
| 624 | elif token in [14]:
|
|---|
| 625 | self.enterOuterAlt(localctx, 7)
|
|---|
| 626 | self.state = 91
|
|---|
| 627 | self.match(CMODParser.T__13)
|
|---|
| 628 | pass
|
|---|
| 629 | elif token in [15]:
|
|---|
| 630 | self.enterOuterAlt(localctx, 8)
|
|---|
| 631 | self.state = 92
|
|---|
| 632 | self.match(CMODParser.T__14)
|
|---|
| 633 | self.state = 93
|
|---|
| 634 | self.match(CMODParser.Identifier)
|
|---|
| 635 | pass
|
|---|
| 636 | else:
|
|---|
| 637 | raise NoViableAltException(self)
|
|---|
| 638 |
|
|---|
| 639 | except RecognitionException as re:
|
|---|
| 640 | localctx.exception = re
|
|---|
| 641 | self._errHandler.reportError(self, re)
|
|---|
| 642 | self._errHandler.recover(self, re)
|
|---|
| 643 | finally:
|
|---|
| 644 | self.exitRule()
|
|---|
| 645 | return localctx
|
|---|
| 646 |
|
|---|
| 647 |
|
|---|
| 648 | class LimitedDeclaratorContext(ParserRuleContext):
|
|---|
| 649 | __slots__ = 'parser'
|
|---|
| 650 |
|
|---|
| 651 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 652 | super().__init__(parent, invokingState)
|
|---|
| 653 | self.parser = parser
|
|---|
| 654 |
|
|---|
| 655 | def Identifier(self):
|
|---|
| 656 | return self.getToken(CMODParser.Identifier, 0)
|
|---|
| 657 |
|
|---|
| 658 | def getRuleIndex(self):
|
|---|
| 659 | return CMODParser.RULE_limitedDeclarator
|
|---|
| 660 |
|
|---|
| 661 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 662 | if hasattr( listener, "enterLimitedDeclarator" ):
|
|---|
| 663 | listener.enterLimitedDeclarator(self)
|
|---|
| 664 |
|
|---|
| 665 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 666 | if hasattr( listener, "exitLimitedDeclarator" ):
|
|---|
| 667 | listener.exitLimitedDeclarator(self)
|
|---|
| 668 |
|
|---|
| 669 |
|
|---|
| 670 |
|
|---|
| 671 |
|
|---|
| 672 | def limitedDeclarator(self):
|
|---|
| 673 |
|
|---|
| 674 | localctx = CMODParser.LimitedDeclaratorContext(self, self._ctx, self.state)
|
|---|
| 675 | self.enterRule(localctx, 14, self.RULE_limitedDeclarator)
|
|---|
| 676 | self._la = 0 # Token type
|
|---|
| 677 | try:
|
|---|
| 678 | self.enterOuterAlt(localctx, 1)
|
|---|
| 679 | self.state = 97
|
|---|
| 680 | self._errHandler.sync(self)
|
|---|
| 681 | _la = self._input.LA(1)
|
|---|
| 682 | if _la==16:
|
|---|
| 683 | self.state = 96
|
|---|
| 684 | self.match(CMODParser.T__15)
|
|---|
| 685 |
|
|---|
| 686 |
|
|---|
| 687 | self.state = 99
|
|---|
| 688 | self.match(CMODParser.Identifier)
|
|---|
| 689 | except RecognitionException as re:
|
|---|
| 690 | localctx.exception = re
|
|---|
| 691 | self._errHandler.reportError(self, re)
|
|---|
| 692 | self._errHandler.recover(self, re)
|
|---|
| 693 | finally:
|
|---|
| 694 | self.exitRule()
|
|---|
| 695 | return localctx
|
|---|
| 696 |
|
|---|
| 697 |
|
|---|
| 698 | class LimitedParameterListContext(ParserRuleContext):
|
|---|
| 699 | __slots__ = 'parser'
|
|---|
| 700 |
|
|---|
| 701 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 702 | super().__init__(parent, invokingState)
|
|---|
| 703 | self.parser = parser
|
|---|
| 704 |
|
|---|
| 705 | def limitedTypeSpecifier(self, i:int=None):
|
|---|
| 706 | if i is None:
|
|---|
| 707 | return self.getTypedRuleContexts(CMODParser.LimitedTypeSpecifierContext)
|
|---|
| 708 | else:
|
|---|
| 709 | return self.getTypedRuleContext(CMODParser.LimitedTypeSpecifierContext,i)
|
|---|
| 710 |
|
|---|
| 711 |
|
|---|
| 712 | def limitedDeclarator(self, i:int=None):
|
|---|
| 713 | if i is None:
|
|---|
| 714 | return self.getTypedRuleContexts(CMODParser.LimitedDeclaratorContext)
|
|---|
| 715 | else:
|
|---|
| 716 | return self.getTypedRuleContext(CMODParser.LimitedDeclaratorContext,i)
|
|---|
| 717 |
|
|---|
| 718 |
|
|---|
| 719 | def getRuleIndex(self):
|
|---|
| 720 | return CMODParser.RULE_limitedParameterList
|
|---|
| 721 |
|
|---|
| 722 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 723 | if hasattr( listener, "enterLimitedParameterList" ):
|
|---|
| 724 | listener.enterLimitedParameterList(self)
|
|---|
| 725 |
|
|---|
| 726 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 727 | if hasattr( listener, "exitLimitedParameterList" ):
|
|---|
| 728 | listener.exitLimitedParameterList(self)
|
|---|
| 729 |
|
|---|
| 730 |
|
|---|
| 731 |
|
|---|
| 732 |
|
|---|
| 733 | def limitedParameterList(self):
|
|---|
| 734 |
|
|---|
| 735 | localctx = CMODParser.LimitedParameterListContext(self, self._ctx, self.state)
|
|---|
| 736 | self.enterRule(localctx, 16, self.RULE_limitedParameterList)
|
|---|
| 737 | self._la = 0 # Token type
|
|---|
| 738 | try:
|
|---|
| 739 | self.enterOuterAlt(localctx, 1)
|
|---|
| 740 | self.state = 101
|
|---|
| 741 | self.limitedTypeSpecifier()
|
|---|
| 742 | self.state = 102
|
|---|
| 743 | self.limitedDeclarator()
|
|---|
| 744 | self.state = 109
|
|---|
| 745 | self._errHandler.sync(self)
|
|---|
| 746 | _la = self._input.LA(1)
|
|---|
| 747 | while _la==17:
|
|---|
| 748 | self.state = 103
|
|---|
| 749 | self.match(CMODParser.T__16)
|
|---|
| 750 | self.state = 104
|
|---|
| 751 | self.limitedTypeSpecifier()
|
|---|
| 752 | self.state = 105
|
|---|
| 753 | self.limitedDeclarator()
|
|---|
| 754 | self.state = 111
|
|---|
| 755 | self._errHandler.sync(self)
|
|---|
| 756 | _la = self._input.LA(1)
|
|---|
| 757 |
|
|---|
| 758 | except RecognitionException as re:
|
|---|
| 759 | localctx.exception = re
|
|---|
| 760 | self._errHandler.reportError(self, re)
|
|---|
| 761 | self._errHandler.recover(self, re)
|
|---|
| 762 | finally:
|
|---|
| 763 | self.exitRule()
|
|---|
| 764 | return localctx
|
|---|
| 765 |
|
|---|
| 766 |
|
|---|
| 767 | class LimitedCompoundStatementContext(ParserRuleContext):
|
|---|
| 768 | __slots__ = 'parser'
|
|---|
| 769 |
|
|---|
| 770 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 771 | super().__init__(parent, invokingState)
|
|---|
| 772 | self.parser = parser
|
|---|
| 773 |
|
|---|
| 774 | def limitedStatement(self, i:int=None):
|
|---|
| 775 | if i is None:
|
|---|
| 776 | return self.getTypedRuleContexts(CMODParser.LimitedStatementContext)
|
|---|
| 777 | else:
|
|---|
| 778 | return self.getTypedRuleContext(CMODParser.LimitedStatementContext,i)
|
|---|
| 779 |
|
|---|
| 780 |
|
|---|
| 781 | def getRuleIndex(self):
|
|---|
| 782 | return CMODParser.RULE_limitedCompoundStatement
|
|---|
| 783 |
|
|---|
| 784 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 785 | if hasattr( listener, "enterLimitedCompoundStatement" ):
|
|---|
| 786 | listener.enterLimitedCompoundStatement(self)
|
|---|
| 787 |
|
|---|
| 788 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 789 | if hasattr( listener, "exitLimitedCompoundStatement" ):
|
|---|
| 790 | listener.exitLimitedCompoundStatement(self)
|
|---|
| 791 |
|
|---|
| 792 |
|
|---|
| 793 |
|
|---|
| 794 |
|
|---|
| 795 | def limitedCompoundStatement(self):
|
|---|
| 796 |
|
|---|
| 797 | localctx = CMODParser.LimitedCompoundStatementContext(self, self._ctx, self.state)
|
|---|
| 798 | self.enterRule(localctx, 18, self.RULE_limitedCompoundStatement)
|
|---|
| 799 | self._la = 0 # Token type
|
|---|
| 800 | try:
|
|---|
| 801 | self.enterOuterAlt(localctx, 1)
|
|---|
| 802 | self.state = 112
|
|---|
| 803 | self.match(CMODParser.T__17)
|
|---|
| 804 | self.state = 116
|
|---|
| 805 | self._errHandler.sync(self)
|
|---|
| 806 | _la = self._input.LA(1)
|
|---|
| 807 | while _la==20 or _la==23:
|
|---|
| 808 | self.state = 113
|
|---|
| 809 | self.limitedStatement()
|
|---|
| 810 | self.state = 118
|
|---|
| 811 | self._errHandler.sync(self)
|
|---|
| 812 | _la = self._input.LA(1)
|
|---|
| 813 |
|
|---|
| 814 | self.state = 119
|
|---|
| 815 | self.match(CMODParser.T__18)
|
|---|
| 816 | except RecognitionException as re:
|
|---|
| 817 | localctx.exception = re
|
|---|
| 818 | self._errHandler.reportError(self, re)
|
|---|
| 819 | self._errHandler.recover(self, re)
|
|---|
| 820 | finally:
|
|---|
| 821 | self.exitRule()
|
|---|
| 822 | return localctx
|
|---|
| 823 |
|
|---|
| 824 |
|
|---|
| 825 | class LimitedStatementContext(ParserRuleContext):
|
|---|
| 826 | __slots__ = 'parser'
|
|---|
| 827 |
|
|---|
| 828 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 829 | super().__init__(parent, invokingState)
|
|---|
| 830 | self.parser = parser
|
|---|
| 831 |
|
|---|
| 832 | def Identifier(self):
|
|---|
| 833 | return self.getToken(CMODParser.Identifier, 0)
|
|---|
| 834 |
|
|---|
| 835 | def getRuleIndex(self):
|
|---|
| 836 | return CMODParser.RULE_limitedStatement
|
|---|
| 837 |
|
|---|
| 838 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 839 | if hasattr( listener, "enterLimitedStatement" ):
|
|---|
| 840 | listener.enterLimitedStatement(self)
|
|---|
| 841 |
|
|---|
| 842 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 843 | if hasattr( listener, "exitLimitedStatement" ):
|
|---|
| 844 | listener.exitLimitedStatement(self)
|
|---|
| 845 |
|
|---|
| 846 |
|
|---|
| 847 |
|
|---|
| 848 |
|
|---|
| 849 | def limitedStatement(self):
|
|---|
| 850 |
|
|---|
| 851 | localctx = CMODParser.LimitedStatementContext(self, self._ctx, self.state)
|
|---|
| 852 | self.enterRule(localctx, 20, self.RULE_limitedStatement)
|
|---|
| 853 | try:
|
|---|
| 854 | self.state = 130
|
|---|
| 855 | self._errHandler.sync(self)
|
|---|
| 856 | la_ = self._interp.adaptivePredict(self._input,13,self._ctx)
|
|---|
| 857 | if la_ == 1:
|
|---|
| 858 | self.enterOuterAlt(localctx, 1)
|
|---|
| 859 | self.state = 121
|
|---|
| 860 | self.match(CMODParser.Identifier)
|
|---|
| 861 | self.state = 122
|
|---|
| 862 | self.match(CMODParser.T__1)
|
|---|
| 863 | pass
|
|---|
| 864 |
|
|---|
| 865 | elif la_ == 2:
|
|---|
| 866 | self.enterOuterAlt(localctx, 2)
|
|---|
| 867 | self.state = 123
|
|---|
| 868 | self.match(CMODParser.T__19)
|
|---|
| 869 | self.state = 124
|
|---|
| 870 | self.match(CMODParser.Identifier)
|
|---|
| 871 | self.state = 125
|
|---|
| 872 | self.match(CMODParser.T__1)
|
|---|
| 873 | pass
|
|---|
| 874 |
|
|---|
| 875 | elif la_ == 3:
|
|---|
| 876 | self.enterOuterAlt(localctx, 3)
|
|---|
| 877 | self.state = 126
|
|---|
| 878 | self.match(CMODParser.T__19)
|
|---|
| 879 | self.state = 127
|
|---|
| 880 | self.match(CMODParser.T__15)
|
|---|
| 881 | self.state = 128
|
|---|
| 882 | self.match(CMODParser.Identifier)
|
|---|
| 883 | self.state = 129
|
|---|
| 884 | self.match(CMODParser.T__1)
|
|---|
| 885 | pass
|
|---|
| 886 |
|
|---|
| 887 |
|
|---|
| 888 | except RecognitionException as re:
|
|---|
| 889 | localctx.exception = re
|
|---|
| 890 | self._errHandler.reportError(self, re)
|
|---|
| 891 | self._errHandler.recover(self, re)
|
|---|
| 892 | finally:
|
|---|
| 893 | self.exitRule()
|
|---|
| 894 | return localctx
|
|---|
| 895 |
|
|---|
| 896 |
|
|---|
| 897 | class LimitedGlobalContext(ParserRuleContext):
|
|---|
| 898 | __slots__ = 'parser'
|
|---|
| 899 |
|
|---|
| 900 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 901 | super().__init__(parent, invokingState)
|
|---|
| 902 | self.parser = parser
|
|---|
| 903 |
|
|---|
| 904 | def limitedTypeSpecifier(self):
|
|---|
| 905 | return self.getTypedRuleContext(CMODParser.LimitedTypeSpecifierContext,0)
|
|---|
| 906 |
|
|---|
| 907 |
|
|---|
| 908 | def limitedDeclarator(self):
|
|---|
| 909 | return self.getTypedRuleContext(CMODParser.LimitedDeclaratorContext,0)
|
|---|
| 910 |
|
|---|
| 911 |
|
|---|
| 912 | def limitedInitializer(self):
|
|---|
| 913 | return self.getTypedRuleContext(CMODParser.LimitedInitializerContext,0)
|
|---|
| 914 |
|
|---|
| 915 |
|
|---|
| 916 | def getRuleIndex(self):
|
|---|
| 917 | return CMODParser.RULE_limitedGlobal
|
|---|
| 918 |
|
|---|
| 919 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 920 | if hasattr( listener, "enterLimitedGlobal" ):
|
|---|
| 921 | listener.enterLimitedGlobal(self)
|
|---|
| 922 |
|
|---|
| 923 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 924 | if hasattr( listener, "exitLimitedGlobal" ):
|
|---|
| 925 | listener.exitLimitedGlobal(self)
|
|---|
| 926 |
|
|---|
| 927 |
|
|---|
| 928 |
|
|---|
| 929 |
|
|---|
| 930 | def limitedGlobal(self):
|
|---|
| 931 |
|
|---|
| 932 | localctx = CMODParser.LimitedGlobalContext(self, self._ctx, self.state)
|
|---|
| 933 | self.enterRule(localctx, 22, self.RULE_limitedGlobal)
|
|---|
| 934 | self._la = 0 # Token type
|
|---|
| 935 | try:
|
|---|
| 936 | self.enterOuterAlt(localctx, 1)
|
|---|
| 937 | self.state = 132
|
|---|
| 938 | self.limitedTypeSpecifier()
|
|---|
| 939 | self.state = 133
|
|---|
| 940 | self.limitedDeclarator()
|
|---|
| 941 | self.state = 136
|
|---|
| 942 | self._errHandler.sync(self)
|
|---|
| 943 | _la = self._input.LA(1)
|
|---|
| 944 | if _la==21:
|
|---|
| 945 | self.state = 134
|
|---|
| 946 | self.match(CMODParser.T__20)
|
|---|
| 947 | self.state = 135
|
|---|
| 948 | self.limitedInitializer()
|
|---|
| 949 |
|
|---|
| 950 |
|
|---|
| 951 | self.state = 138
|
|---|
| 952 | self.match(CMODParser.T__1)
|
|---|
| 953 | except RecognitionException as re:
|
|---|
| 954 | localctx.exception = re
|
|---|
| 955 | self._errHandler.reportError(self, re)
|
|---|
| 956 | self._errHandler.recover(self, re)
|
|---|
| 957 | finally:
|
|---|
| 958 | self.exitRule()
|
|---|
| 959 | return localctx
|
|---|
| 960 |
|
|---|
| 961 |
|
|---|
| 962 | class LimitedInitializerContext(ParserRuleContext):
|
|---|
| 963 | __slots__ = 'parser'
|
|---|
| 964 |
|
|---|
| 965 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 966 | super().__init__(parent, invokingState)
|
|---|
| 967 | self.parser = parser
|
|---|
| 968 |
|
|---|
| 969 | def Identifier(self, i:int=None):
|
|---|
| 970 | if i is None:
|
|---|
| 971 | return self.getTokens(CMODParser.Identifier)
|
|---|
| 972 | else:
|
|---|
| 973 | return self.getToken(CMODParser.Identifier, i)
|
|---|
| 974 |
|
|---|
| 975 | def getRuleIndex(self):
|
|---|
| 976 | return CMODParser.RULE_limitedInitializer
|
|---|
| 977 |
|
|---|
| 978 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 979 | if hasattr( listener, "enterLimitedInitializer" ):
|
|---|
| 980 | listener.enterLimitedInitializer(self)
|
|---|
| 981 |
|
|---|
| 982 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 983 | if hasattr( listener, "exitLimitedInitializer" ):
|
|---|
| 984 | listener.exitLimitedInitializer(self)
|
|---|
| 985 |
|
|---|
| 986 |
|
|---|
| 987 |
|
|---|
| 988 |
|
|---|
| 989 | def limitedInitializer(self):
|
|---|
| 990 |
|
|---|
| 991 | localctx = CMODParser.LimitedInitializerContext(self, self._ctx, self.state)
|
|---|
| 992 | self.enterRule(localctx, 24, self.RULE_limitedInitializer)
|
|---|
| 993 | self._la = 0 # Token type
|
|---|
| 994 | try:
|
|---|
| 995 | self.enterOuterAlt(localctx, 1)
|
|---|
| 996 | self.state = 140
|
|---|
| 997 | self.match(CMODParser.Identifier)
|
|---|
| 998 | self.state = 145
|
|---|
| 999 | self._errHandler.sync(self)
|
|---|
| 1000 | _la = self._input.LA(1)
|
|---|
| 1001 | while _la==22:
|
|---|
| 1002 | self.state = 141
|
|---|
| 1003 | self.match(CMODParser.T__21)
|
|---|
| 1004 | self.state = 142
|
|---|
| 1005 | self.match(CMODParser.Identifier)
|
|---|
| 1006 | self.state = 147
|
|---|
| 1007 | self._errHandler.sync(self)
|
|---|
| 1008 | _la = self._input.LA(1)
|
|---|
| 1009 |
|
|---|
| 1010 | except RecognitionException as re:
|
|---|
| 1011 | localctx.exception = re
|
|---|
| 1012 | self._errHandler.reportError(self, re)
|
|---|
| 1013 | self._errHandler.recover(self, re)
|
|---|
| 1014 | finally:
|
|---|
| 1015 | self.exitRule()
|
|---|
| 1016 | return localctx
|
|---|
| 1017 |
|
|---|
| 1018 |
|
|---|
| 1019 | class LimitedStructContext(ParserRuleContext):
|
|---|
| 1020 | __slots__ = 'parser'
|
|---|
| 1021 |
|
|---|
| 1022 | def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
|---|
| 1023 | super().__init__(parent, invokingState)
|
|---|
| 1024 | self.parser = parser
|
|---|
| 1025 |
|
|---|
| 1026 | def Identifier(self):
|
|---|
| 1027 | return self.getToken(CMODParser.Identifier, 0)
|
|---|
| 1028 |
|
|---|
| 1029 | def limitedCompoundStatement(self):
|
|---|
| 1030 | return self.getTypedRuleContext(CMODParser.LimitedCompoundStatementContext,0)
|
|---|
| 1031 |
|
|---|
| 1032 |
|
|---|
| 1033 | def getRuleIndex(self):
|
|---|
| 1034 | return CMODParser.RULE_limitedStruct
|
|---|
| 1035 |
|
|---|
| 1036 | def enterRule(self, listener:ParseTreeListener):
|
|---|
| 1037 | if hasattr( listener, "enterLimitedStruct" ):
|
|---|
| 1038 | listener.enterLimitedStruct(self)
|
|---|
| 1039 |
|
|---|
| 1040 | def exitRule(self, listener:ParseTreeListener):
|
|---|
| 1041 | if hasattr( listener, "exitLimitedStruct" ):
|
|---|
| 1042 | listener.exitLimitedStruct(self)
|
|---|
| 1043 |
|
|---|
| 1044 |
|
|---|
| 1045 |
|
|---|
| 1046 |
|
|---|
| 1047 | def limitedStruct(self):
|
|---|
| 1048 |
|
|---|
| 1049 | localctx = CMODParser.LimitedStructContext(self, self._ctx, self.state)
|
|---|
| 1050 | self.enterRule(localctx, 26, self.RULE_limitedStruct)
|
|---|
| 1051 | try:
|
|---|
| 1052 | self.enterOuterAlt(localctx, 1)
|
|---|
| 1053 | self.state = 148
|
|---|
| 1054 | self.match(CMODParser.T__14)
|
|---|
| 1055 | self.state = 149
|
|---|
| 1056 | self.match(CMODParser.Identifier)
|
|---|
| 1057 | self.state = 150
|
|---|
| 1058 | self.limitedCompoundStatement()
|
|---|
| 1059 | self.state = 151
|
|---|
| 1060 | self.match(CMODParser.T__1)
|
|---|
| 1061 | except RecognitionException as re:
|
|---|
| 1062 | localctx.exception = re
|
|---|
| 1063 | self._errHandler.reportError(self, re)
|
|---|
| 1064 | self._errHandler.recover(self, re)
|
|---|
| 1065 | finally:
|
|---|
| 1066 | self.exitRule()
|
|---|
| 1067 | return localctx
|
|---|
| 1068 |
|
|---|
| 1069 |
|
|---|
| 1070 |
|
|---|
| 1071 |
|
|---|
| 1072 |
|
|---|