parser.go 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385
  1. // Code generated by goyacc -o parser.go parser.go.y. DO NOT EDIT.
  2. //line parser.go.y:2
  3. package parse
  4. import __yyfmt__ "fmt"
  5. //line parser.go.y:2
  6. import (
  7. "github.com/yuin/gopher-lua/ast"
  8. )
  9. //line parser.go.y:34
  10. type yySymType struct {
  11. yys int
  12. token ast.Token
  13. stmts []ast.Stmt
  14. stmt ast.Stmt
  15. funcname *ast.FuncName
  16. funcexpr *ast.FunctionExpr
  17. exprlist []ast.Expr
  18. expr ast.Expr
  19. fieldlist []*ast.Field
  20. field *ast.Field
  21. fieldsep string
  22. namelist []string
  23. parlist *ast.ParList
  24. }
  25. const TAnd = 57346
  26. const TBreak = 57347
  27. const TDo = 57348
  28. const TElse = 57349
  29. const TElseIf = 57350
  30. const TEnd = 57351
  31. const TFalse = 57352
  32. const TFor = 57353
  33. const TFunction = 57354
  34. const TIf = 57355
  35. const TIn = 57356
  36. const TLocal = 57357
  37. const TNil = 57358
  38. const TNot = 57359
  39. const TOr = 57360
  40. const TReturn = 57361
  41. const TRepeat = 57362
  42. const TThen = 57363
  43. const TTrue = 57364
  44. const TUntil = 57365
  45. const TWhile = 57366
  46. const TGoto = 57367
  47. const TEqeq = 57368
  48. const TNeq = 57369
  49. const TLte = 57370
  50. const TGte = 57371
  51. const T2Comma = 57372
  52. const T3Comma = 57373
  53. const T2Colon = 57374
  54. const TIdent = 57375
  55. const TNumber = 57376
  56. const TString = 57377
  57. const UNARY = 57378
  58. var yyToknames = [...]string{
  59. "$end",
  60. "error",
  61. "$unk",
  62. "TAnd",
  63. "TBreak",
  64. "TDo",
  65. "TElse",
  66. "TElseIf",
  67. "TEnd",
  68. "TFalse",
  69. "TFor",
  70. "TFunction",
  71. "TIf",
  72. "TIn",
  73. "TLocal",
  74. "TNil",
  75. "TNot",
  76. "TOr",
  77. "TReturn",
  78. "TRepeat",
  79. "TThen",
  80. "TTrue",
  81. "TUntil",
  82. "TWhile",
  83. "TGoto",
  84. "TEqeq",
  85. "TNeq",
  86. "TLte",
  87. "TGte",
  88. "T2Comma",
  89. "T3Comma",
  90. "T2Colon",
  91. "TIdent",
  92. "TNumber",
  93. "TString",
  94. "'{'",
  95. "'('",
  96. "'>'",
  97. "'<'",
  98. "'+'",
  99. "'-'",
  100. "'*'",
  101. "'/'",
  102. "'%'",
  103. "UNARY",
  104. "'^'",
  105. "';'",
  106. "'='",
  107. "','",
  108. "':'",
  109. "'.'",
  110. "'['",
  111. "']'",
  112. "'#'",
  113. "')'",
  114. "'}'",
  115. }
  116. var yyStatenames = [...]string{}
  117. const yyEofCode = 1
  118. const yyErrCode = 2
  119. const yyInitialStackSize = 16
  120. //line parser.go.y:525
  121. func TokenName(c int) string {
  122. if c >= TAnd && c-TAnd < len(yyToknames) {
  123. if yyToknames[c-TAnd] != "" {
  124. return yyToknames[c-TAnd]
  125. }
  126. }
  127. return string([]byte{byte(c)})
  128. }
  129. //line yacctab:1
  130. var yyExca = [...]int8{
  131. -1, 1,
  132. 1, -1,
  133. -2, 0,
  134. -1, 19,
  135. 48, 33,
  136. 49, 33,
  137. -2, 70,
  138. -1, 97,
  139. 48, 34,
  140. 49, 34,
  141. -2, 70,
  142. }
  143. const yyPrivate = 57344
  144. const yyLast = 616
  145. var yyAct = [...]uint8{
  146. 26, 92, 52, 25, 47, 88, 158, 58, 142, 118,
  147. 141, 167, 54, 69, 56, 55, 35, 139, 41, 42,
  148. 49, 160, 34, 67, 63, 137, 50, 64, 112, 113,
  149. 69, 109, 51, 48, 46, 45, 147, 85, 86, 87,
  150. 115, 110, 24, 95, 43, 44, 99, 96, 78, 136,
  151. 50, 171, 143, 103, 69, 108, 51, 84, 79, 80,
  152. 81, 82, 83, 89, 84, 111, 110, 41, 42, 49,
  153. 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
  154. 129, 130, 131, 132, 133, 134, 81, 82, 83, 170,
  155. 84, 153, 155, 33, 154, 144, 9, 138, 40, 23,
  156. 153, 19, 62, 22, 114, 101, 146, 149, 148, 151,
  157. 150, 71, 100, 152, 66, 50, 65, 61, 50, 157,
  158. 156, 51, 57, 64, 51, 70, 116, 106, 192, 21,
  159. 173, 174, 172, 76, 77, 75, 74, 78, 98, 159,
  160. 189, 95, 161, 97, 162, 72, 73, 79, 80, 81,
  161. 82, 83, 68, 84, 184, 183, 177, 169, 164, 104,
  162. 140, 168, 117, 53, 1, 91, 135, 175, 32, 20,
  163. 176, 8, 178, 60, 59, 180, 179, 3, 165, 28,
  164. 4, 39, 2, 187, 186, 27, 37, 0, 188, 0,
  165. 0, 29, 0, 191, 71, 0, 0, 0, 0, 0,
  166. 31, 0, 93, 30, 41, 42, 22, 0, 70, 0,
  167. 36, 0, 0, 0, 0, 0, 76, 77, 75, 74,
  168. 78, 94, 0, 38, 71, 90, 0, 0, 72, 73,
  169. 79, 80, 81, 82, 83, 0, 84, 0, 70, 0,
  170. 0, 0, 0, 163, 0, 0, 76, 77, 75, 74,
  171. 78, 0, 0, 0, 0, 0, 0, 0, 72, 73,
  172. 79, 80, 81, 82, 83, 28, 84, 39, 0, 0,
  173. 0, 27, 37, 145, 0, 0, 0, 29, 0, 0,
  174. 0, 0, 0, 0, 0, 0, 31, 0, 23, 30,
  175. 41, 42, 22, 28, 0, 39, 36, 0, 0, 27,
  176. 37, 0, 0, 0, 0, 29, 0, 0, 0, 38,
  177. 102, 0, 0, 0, 31, 0, 93, 30, 41, 42,
  178. 22, 28, 0, 39, 36, 0, 0, 27, 37, 0,
  179. 0, 0, 0, 29, 0, 94, 71, 38, 181, 0,
  180. 0, 0, 31, 0, 23, 30, 41, 42, 22, 0,
  181. 70, 0, 36, 0, 0, 0, 0, 0, 76, 77,
  182. 75, 74, 78, 71, 0, 38, 0, 0, 0, 0,
  183. 72, 73, 79, 80, 81, 82, 83, 70, 84, 0,
  184. 0, 182, 0, 0, 0, 76, 77, 75, 74, 78,
  185. 71, 0, 190, 0, 0, 0, 0, 72, 73, 79,
  186. 80, 81, 82, 83, 70, 84, 0, 0, 166, 0,
  187. 0, 0, 76, 77, 75, 74, 78, 71, 0, 0,
  188. 0, 0, 0, 0, 72, 73, 79, 80, 81, 82,
  189. 83, 70, 84, 0, 185, 0, 0, 0, 0, 76,
  190. 77, 75, 74, 78, 71, 0, 0, 0, 0, 0,
  191. 0, 72, 73, 79, 80, 81, 82, 83, 70, 84,
  192. 0, 107, 0, 0, 0, 0, 76, 77, 75, 74,
  193. 78, 71, 0, 105, 0, 0, 0, 0, 72, 73,
  194. 79, 80, 81, 82, 83, 70, 84, 0, 0, 0,
  195. 0, 0, 0, 76, 77, 75, 74, 78, 71, 0,
  196. 0, 0, 0, 0, 0, 72, 73, 79, 80, 81,
  197. 82, 83, 70, 84, 0, 0, 0, 0, 0, 0,
  198. 76, 77, 75, 74, 78, 0, 0, 0, 0, 0,
  199. 0, 0, 72, 73, 79, 80, 81, 82, 83, 0,
  200. 84, 7, 10, 0, 0, 0, 0, 14, 15, 13,
  201. 0, 16, 71, 0, 0, 6, 12, 0, 0, 0,
  202. 11, 18, 0, 0, 0, 0, 0, 0, 17, 23,
  203. 0, 0, 0, 22, 76, 77, 75, 74, 78, 0,
  204. 0, 0, 0, 5, 0, 0, 72, 73, 79, 80,
  205. 81, 82, 83, 0, 84, 76, 77, 75, 74, 78,
  206. 0, 0, 0, 0, 0, 0, 0, 72, 73, 79,
  207. 80, 81, 82, 83, 0, 84,
  208. }
  209. var yyPact = [...]int16{
  210. -1000, -1000, 536, -5, -1000, -1000, 311, -1000, -4, -17,
  211. -1000, 311, -1000, 311, 89, 84, 90, 83, 81, -1000,
  212. -1000, -1000, 311, -1000, -1000, -36, 494, -1000, -1000, -1000,
  213. -1000, -1000, -1000, -17, -1000, -1000, 311, 311, 311, 26,
  214. -1000, -1000, 169, 311, 66, 311, 79, -1000, 72, 255,
  215. -1000, -1000, 150, -1000, 467, 104, 440, 7, 17, 26,
  216. -22, -1000, 71, -8, -1000, 94, -1000, 107, -46, 311,
  217. 311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
  218. 311, 311, 311, 311, 311, 11, 11, 11, -1000, -6,
  219. -1000, -39, -1000, 4, 311, 494, -36, -1000, -17, 220,
  220. -1000, 32, -1000, -19, -1000, -1000, 311, -1000, 311, 311,
  221. 67, -1000, 61, 59, 26, 311, -1000, -1000, -1000, 494,
  222. 548, 569, 18, 18, 18, 18, 18, 18, 18, 44,
  223. 44, 11, 11, 11, 11, -49, -1000, -1000, -28, -1000,
  224. 283, -1000, -1000, 311, 190, -1000, -1000, -1000, 149, 494,
  225. -1000, 359, 5, -1000, -1000, -1000, -1000, -36, -1000, 148,
  226. 58, -1000, 494, 3, -1000, 123, 311, -1000, 147, -1000,
  227. -1000, 311, -1000, -1000, 311, 332, 146, -1000, 494, 145,
  228. 413, -1000, 311, -1000, -1000, -1000, 131, 386, -1000, -1000,
  229. -1000, 119, -1000,
  230. }
  231. var yyPgo = [...]uint8{
  232. 0, 163, 182, 2, 180, 178, 177, 174, 173, 171,
  233. 98, 7, 3, 0, 22, 93, 129, 169, 4, 168,
  234. 5, 166, 16, 165, 1, 160,
  235. }
  236. var yyR1 = [...]int8{
  237. 0, 1, 1, 1, 2, 2, 2, 3, 4, 4,
  238. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  239. 4, 4, 4, 4, 5, 5, 6, 6, 6, 7,
  240. 7, 8, 8, 9, 9, 10, 10, 10, 11, 11,
  241. 12, 12, 13, 13, 13, 13, 13, 13, 13, 13,
  242. 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
  243. 13, 13, 13, 13, 13, 13, 13, 13, 13, 14,
  244. 15, 15, 15, 15, 17, 16, 16, 18, 18, 18,
  245. 18, 19, 20, 20, 21, 21, 21, 22, 22, 23,
  246. 23, 23, 24, 24, 24, 25, 25,
  247. }
  248. var yyR2 = [...]int8{
  249. 0, 1, 2, 3, 0, 2, 2, 1, 3, 1,
  250. 3, 5, 4, 6, 8, 9, 11, 7, 3, 4,
  251. 4, 2, 3, 2, 0, 5, 1, 2, 1, 1,
  252. 3, 1, 3, 1, 3, 1, 4, 3, 1, 3,
  253. 1, 3, 1, 1, 1, 1, 1, 1, 1, 1,
  254. 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  255. 3, 3, 3, 3, 3, 3, 2, 2, 2, 1,
  256. 1, 1, 1, 3, 3, 2, 4, 2, 3, 1,
  257. 1, 2, 5, 4, 1, 1, 3, 2, 3, 1,
  258. 3, 2, 3, 5, 1, 1, 1,
  259. }
  260. var yyChk = [...]int16{
  261. -1000, -1, -2, -6, -4, 47, 19, 5, -9, -15,
  262. 6, 24, 20, 13, 11, 12, 15, 32, 25, -10,
  263. -17, -16, 37, 33, 47, -12, -13, 16, 10, 22,
  264. 34, 31, -19, -15, -14, -22, 41, 17, 54, 12,
  265. -10, 35, 36, 48, 49, 52, 51, -18, 50, 37,
  266. -22, -14, -3, -1, -13, -3, -13, 33, -11, -7,
  267. -8, 33, 12, -11, 33, 33, 33, -13, -16, 49,
  268. 18, 4, 38, 39, 29, 28, 26, 27, 30, 40,
  269. 41, 42, 43, 44, 46, -13, -13, -13, -20, 37,
  270. 56, -23, -24, 33, 52, -13, -12, -10, -15, -13,
  271. 33, 33, 55, -12, 9, 6, 23, 21, 48, 14,
  272. 49, -20, 50, 51, 33, 48, 32, 55, 55, -13,
  273. -13, -13, -13, -13, -13, -13, -13, -13, -13, -13,
  274. -13, -13, -13, -13, -13, -21, 55, 31, -11, 56,
  275. -25, 49, 47, 48, -13, 53, -18, 55, -3, -13,
  276. -3, -13, -12, 33, 33, 33, -20, -12, 55, -3,
  277. 49, -24, -13, 53, 9, -5, 49, 6, -3, 9,
  278. 31, 48, 9, 7, 8, -13, -3, 9, -13, -3,
  279. -13, 6, 49, 9, 9, 21, -3, -13, -3, 9,
  280. 6, -3, 9,
  281. }
  282. var yyDef = [...]int8{
  283. 4, -2, 1, 2, 5, 6, 26, 28, 0, 9,
  284. 4, 0, 4, 0, 0, 0, 0, 0, 0, -2,
  285. 71, 72, 0, 35, 3, 27, 40, 42, 43, 44,
  286. 45, 46, 47, 48, 49, 50, 0, 0, 0, 0,
  287. 70, 69, 0, 0, 0, 0, 0, 75, 0, 0,
  288. 79, 80, 0, 7, 0, 0, 0, 38, 0, 0,
  289. 29, 31, 0, 21, 38, 0, 23, 0, 72, 0,
  290. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  291. 0, 0, 0, 0, 0, 66, 67, 68, 81, 0,
  292. 87, 0, 89, 35, 0, 94, 8, -2, 0, 0,
  293. 37, 0, 77, 0, 10, 4, 0, 4, 0, 0,
  294. 0, 18, 0, 0, 0, 0, 22, 73, 74, 41,
  295. 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
  296. 61, 62, 63, 64, 65, 0, 4, 84, 85, 88,
  297. 91, 95, 96, 0, 0, 36, 76, 78, 0, 12,
  298. 24, 0, 0, 39, 30, 32, 19, 20, 4, 0,
  299. 0, 90, 92, 0, 11, 0, 0, 4, 0, 83,
  300. 86, 0, 13, 4, 0, 0, 0, 82, 93, 0,
  301. 0, 4, 0, 17, 14, 4, 0, 0, 25, 15,
  302. 4, 0, 16,
  303. }
  304. var yyTok1 = [...]int8{
  305. 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  306. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  307. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  308. 3, 3, 3, 3, 3, 54, 3, 44, 3, 3,
  309. 37, 55, 42, 40, 49, 41, 51, 43, 3, 3,
  310. 3, 3, 3, 3, 3, 3, 3, 3, 50, 47,
  311. 39, 48, 38, 3, 3, 3, 3, 3, 3, 3,
  312. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  313. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  314. 3, 52, 3, 53, 46, 3, 3, 3, 3, 3,
  315. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  316. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  317. 3, 3, 3, 36, 3, 56,
  318. }
  319. var yyTok2 = [...]int8{
  320. 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  321. 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
  322. 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  323. 32, 33, 34, 35, 45,
  324. }
  325. var yyTok3 = [...]int8{
  326. 0,
  327. }
  328. var yyErrorMessages = [...]struct {
  329. state int
  330. token int
  331. msg string
  332. }{}
  333. //line yaccpar:1
  334. /* parser for yacc output */
  335. var (
  336. yyDebug = 0
  337. yyErrorVerbose = false
  338. )
  339. type yyLexer interface {
  340. Lex(lval *yySymType) int
  341. Error(s string)
  342. }
  343. type yyParser interface {
  344. Parse(yyLexer) int
  345. Lookahead() int
  346. }
  347. type yyParserImpl struct {
  348. lval yySymType
  349. stack [yyInitialStackSize]yySymType
  350. char int
  351. }
  352. func (p *yyParserImpl) Lookahead() int {
  353. return p.char
  354. }
  355. func yyNewParser() yyParser {
  356. return &yyParserImpl{}
  357. }
  358. const yyFlag = -1000
  359. func yyTokname(c int) string {
  360. if c >= 1 && c-1 < len(yyToknames) {
  361. if yyToknames[c-1] != "" {
  362. return yyToknames[c-1]
  363. }
  364. }
  365. return __yyfmt__.Sprintf("tok-%v", c)
  366. }
  367. func yyStatname(s int) string {
  368. if s >= 0 && s < len(yyStatenames) {
  369. if yyStatenames[s] != "" {
  370. return yyStatenames[s]
  371. }
  372. }
  373. return __yyfmt__.Sprintf("state-%v", s)
  374. }
  375. func yyErrorMessage(state, lookAhead int) string {
  376. const TOKSTART = 4
  377. if !yyErrorVerbose {
  378. return "syntax error"
  379. }
  380. for _, e := range yyErrorMessages {
  381. if e.state == state && e.token == lookAhead {
  382. return "syntax error: " + e.msg
  383. }
  384. }
  385. res := "syntax error: unexpected " + yyTokname(lookAhead)
  386. // To match Bison, suggest at most four expected tokens.
  387. expected := make([]int, 0, 4)
  388. // Look for shiftable tokens.
  389. base := int(yyPact[state])
  390. for tok := TOKSTART; tok-1 < len(yyToknames); tok++ {
  391. if n := base + tok; n >= 0 && n < yyLast && int(yyChk[int(yyAct[n])]) == tok {
  392. if len(expected) == cap(expected) {
  393. return res
  394. }
  395. expected = append(expected, tok)
  396. }
  397. }
  398. if yyDef[state] == -2 {
  399. i := 0
  400. for yyExca[i] != -1 || int(yyExca[i+1]) != state {
  401. i += 2
  402. }
  403. // Look for tokens that we accept or reduce.
  404. for i += 2; yyExca[i] >= 0; i += 2 {
  405. tok := int(yyExca[i])
  406. if tok < TOKSTART || yyExca[i+1] == 0 {
  407. continue
  408. }
  409. if len(expected) == cap(expected) {
  410. return res
  411. }
  412. expected = append(expected, tok)
  413. }
  414. // If the default action is to accept or reduce, give up.
  415. if yyExca[i+1] != 0 {
  416. return res
  417. }
  418. }
  419. for i, tok := range expected {
  420. if i == 0 {
  421. res += ", expecting "
  422. } else {
  423. res += " or "
  424. }
  425. res += yyTokname(tok)
  426. }
  427. return res
  428. }
  429. func yylex1(lex yyLexer, lval *yySymType) (char, token int) {
  430. token = 0
  431. char = lex.Lex(lval)
  432. if char <= 0 {
  433. token = int(yyTok1[0])
  434. goto out
  435. }
  436. if char < len(yyTok1) {
  437. token = int(yyTok1[char])
  438. goto out
  439. }
  440. if char >= yyPrivate {
  441. if char < yyPrivate+len(yyTok2) {
  442. token = int(yyTok2[char-yyPrivate])
  443. goto out
  444. }
  445. }
  446. for i := 0; i < len(yyTok3); i += 2 {
  447. token = int(yyTok3[i+0])
  448. if token == char {
  449. token = int(yyTok3[i+1])
  450. goto out
  451. }
  452. }
  453. out:
  454. if token == 0 {
  455. token = int(yyTok2[1]) /* unknown char */
  456. }
  457. if yyDebug >= 3 {
  458. __yyfmt__.Printf("lex %s(%d)\n", yyTokname(token), uint(char))
  459. }
  460. return char, token
  461. }
  462. func yyParse(yylex yyLexer) int {
  463. return yyNewParser().Parse(yylex)
  464. }
  465. func (yyrcvr *yyParserImpl) Parse(yylex yyLexer) int {
  466. var yyn int
  467. var yyVAL yySymType
  468. var yyDollar []yySymType
  469. _ = yyDollar // silence set and not used
  470. yyS := yyrcvr.stack[:]
  471. Nerrs := 0 /* number of errors */
  472. Errflag := 0 /* error recovery flag */
  473. yystate := 0
  474. yyrcvr.char = -1
  475. yytoken := -1 // yyrcvr.char translated into internal numbering
  476. defer func() {
  477. // Make sure we report no lookahead when not parsing.
  478. yystate = -1
  479. yyrcvr.char = -1
  480. yytoken = -1
  481. }()
  482. yyp := -1
  483. goto yystack
  484. ret0:
  485. return 0
  486. ret1:
  487. return 1
  488. yystack:
  489. /* put a state and value onto the stack */
  490. if yyDebug >= 4 {
  491. __yyfmt__.Printf("char %v in %v\n", yyTokname(yytoken), yyStatname(yystate))
  492. }
  493. yyp++
  494. if yyp >= len(yyS) {
  495. nyys := make([]yySymType, len(yyS)*2)
  496. copy(nyys, yyS)
  497. yyS = nyys
  498. }
  499. yyS[yyp] = yyVAL
  500. yyS[yyp].yys = yystate
  501. yynewstate:
  502. yyn = int(yyPact[yystate])
  503. if yyn <= yyFlag {
  504. goto yydefault /* simple state */
  505. }
  506. if yyrcvr.char < 0 {
  507. yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval)
  508. }
  509. yyn += yytoken
  510. if yyn < 0 || yyn >= yyLast {
  511. goto yydefault
  512. }
  513. yyn = int(yyAct[yyn])
  514. if int(yyChk[yyn]) == yytoken { /* valid shift */
  515. yyrcvr.char = -1
  516. yytoken = -1
  517. yyVAL = yyrcvr.lval
  518. yystate = yyn
  519. if Errflag > 0 {
  520. Errflag--
  521. }
  522. goto yystack
  523. }
  524. yydefault:
  525. /* default state action */
  526. yyn = int(yyDef[yystate])
  527. if yyn == -2 {
  528. if yyrcvr.char < 0 {
  529. yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval)
  530. }
  531. /* look through exception table */
  532. xi := 0
  533. for {
  534. if yyExca[xi+0] == -1 && int(yyExca[xi+1]) == yystate {
  535. break
  536. }
  537. xi += 2
  538. }
  539. for xi += 2; ; xi += 2 {
  540. yyn = int(yyExca[xi+0])
  541. if yyn < 0 || yyn == yytoken {
  542. break
  543. }
  544. }
  545. yyn = int(yyExca[xi+1])
  546. if yyn < 0 {
  547. goto ret0
  548. }
  549. }
  550. if yyn == 0 {
  551. /* error ... attempt to resume parsing */
  552. switch Errflag {
  553. case 0: /* brand new error */
  554. yylex.Error(yyErrorMessage(yystate, yytoken))
  555. Nerrs++
  556. if yyDebug >= 1 {
  557. __yyfmt__.Printf("%s", yyStatname(yystate))
  558. __yyfmt__.Printf(" saw %s\n", yyTokname(yytoken))
  559. }
  560. fallthrough
  561. case 1, 2: /* incompletely recovered error ... try again */
  562. Errflag = 3
  563. /* find a state where "error" is a legal shift action */
  564. for yyp >= 0 {
  565. yyn = int(yyPact[yyS[yyp].yys]) + yyErrCode
  566. if yyn >= 0 && yyn < yyLast {
  567. yystate = int(yyAct[yyn]) /* simulate a shift of "error" */
  568. if int(yyChk[yystate]) == yyErrCode {
  569. goto yystack
  570. }
  571. }
  572. /* the current p has no shift on "error", pop stack */
  573. if yyDebug >= 2 {
  574. __yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys)
  575. }
  576. yyp--
  577. }
  578. /* there is no state on the stack with an error shift ... abort */
  579. goto ret1
  580. case 3: /* no shift yet; clobber input char */
  581. if yyDebug >= 2 {
  582. __yyfmt__.Printf("error recovery discards %s\n", yyTokname(yytoken))
  583. }
  584. if yytoken == yyEofCode {
  585. goto ret1
  586. }
  587. yyrcvr.char = -1
  588. yytoken = -1
  589. goto yynewstate /* try again in the same state */
  590. }
  591. }
  592. /* reduction by production yyn */
  593. if yyDebug >= 2 {
  594. __yyfmt__.Printf("reduce %v in:\n\t%v\n", yyn, yyStatname(yystate))
  595. }
  596. yynt := yyn
  597. yypt := yyp
  598. _ = yypt // guard against "declared and not used"
  599. yyp -= int(yyR2[yyn])
  600. // yyp is now the index of $0. Perform the default action. Iff the
  601. // reduced production is ε, $1 is possibly out of range.
  602. if yyp+1 >= len(yyS) {
  603. nyys := make([]yySymType, len(yyS)*2)
  604. copy(nyys, yyS)
  605. yyS = nyys
  606. }
  607. yyVAL = yyS[yyp+1]
  608. /* consult goto table to find next state */
  609. yyn = int(yyR1[yyn])
  610. yyg := int(yyPgo[yyn])
  611. yyj := yyg + yyS[yyp].yys + 1
  612. if yyj >= yyLast {
  613. yystate = int(yyAct[yyg])
  614. } else {
  615. yystate = int(yyAct[yyj])
  616. if int(yyChk[yystate]) != -yyn {
  617. yystate = int(yyAct[yyg])
  618. }
  619. }
  620. // dummy call; replaced with literal code
  621. switch yynt {
  622. case 1:
  623. yyDollar = yyS[yypt-1 : yypt+1]
  624. //line parser.go.y:73
  625. {
  626. yyVAL.stmts = yyDollar[1].stmts
  627. if l, ok := yylex.(*Lexer); ok {
  628. l.Stmts = yyVAL.stmts
  629. }
  630. }
  631. case 2:
  632. yyDollar = yyS[yypt-2 : yypt+1]
  633. //line parser.go.y:79
  634. {
  635. yyVAL.stmts = append(yyDollar[1].stmts, yyDollar[2].stmt)
  636. if l, ok := yylex.(*Lexer); ok {
  637. l.Stmts = yyVAL.stmts
  638. }
  639. }
  640. case 3:
  641. yyDollar = yyS[yypt-3 : yypt+1]
  642. //line parser.go.y:85
  643. {
  644. yyVAL.stmts = append(yyDollar[1].stmts, yyDollar[2].stmt)
  645. if l, ok := yylex.(*Lexer); ok {
  646. l.Stmts = yyVAL.stmts
  647. }
  648. }
  649. case 4:
  650. yyDollar = yyS[yypt-0 : yypt+1]
  651. //line parser.go.y:93
  652. {
  653. yyVAL.stmts = []ast.Stmt{}
  654. }
  655. case 5:
  656. yyDollar = yyS[yypt-2 : yypt+1]
  657. //line parser.go.y:96
  658. {
  659. yyVAL.stmts = append(yyDollar[1].stmts, yyDollar[2].stmt)
  660. }
  661. case 6:
  662. yyDollar = yyS[yypt-2 : yypt+1]
  663. //line parser.go.y:99
  664. {
  665. yyVAL.stmts = yyDollar[1].stmts
  666. }
  667. case 7:
  668. yyDollar = yyS[yypt-1 : yypt+1]
  669. //line parser.go.y:104
  670. {
  671. yyVAL.stmts = yyDollar[1].stmts
  672. }
  673. case 8:
  674. yyDollar = yyS[yypt-3 : yypt+1]
  675. //line parser.go.y:109
  676. {
  677. yyVAL.stmt = &ast.AssignStmt{Lhs: yyDollar[1].exprlist, Rhs: yyDollar[3].exprlist}
  678. yyVAL.stmt.SetLine(yyDollar[1].exprlist[0].Line())
  679. }
  680. case 9:
  681. yyDollar = yyS[yypt-1 : yypt+1]
  682. //line parser.go.y:114
  683. {
  684. if _, ok := yyDollar[1].expr.(*ast.FuncCallExpr); !ok {
  685. yylex.(*Lexer).Error("parse error")
  686. } else {
  687. yyVAL.stmt = &ast.FuncCallStmt{Expr: yyDollar[1].expr}
  688. yyVAL.stmt.SetLine(yyDollar[1].expr.Line())
  689. }
  690. }
  691. case 10:
  692. yyDollar = yyS[yypt-3 : yypt+1]
  693. //line parser.go.y:122
  694. {
  695. yyVAL.stmt = &ast.DoBlockStmt{Stmts: yyDollar[2].stmts}
  696. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  697. yyVAL.stmt.SetLastLine(yyDollar[3].token.Pos.Line)
  698. }
  699. case 11:
  700. yyDollar = yyS[yypt-5 : yypt+1]
  701. //line parser.go.y:127
  702. {
  703. yyVAL.stmt = &ast.WhileStmt{Condition: yyDollar[2].expr, Stmts: yyDollar[4].stmts}
  704. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  705. yyVAL.stmt.SetLastLine(yyDollar[5].token.Pos.Line)
  706. }
  707. case 12:
  708. yyDollar = yyS[yypt-4 : yypt+1]
  709. //line parser.go.y:132
  710. {
  711. yyVAL.stmt = &ast.RepeatStmt{Condition: yyDollar[4].expr, Stmts: yyDollar[2].stmts}
  712. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  713. yyVAL.stmt.SetLastLine(yyDollar[4].expr.Line())
  714. }
  715. case 13:
  716. yyDollar = yyS[yypt-6 : yypt+1]
  717. //line parser.go.y:137
  718. {
  719. yyVAL.stmt = &ast.IfStmt{Condition: yyDollar[2].expr, Then: yyDollar[4].stmts}
  720. cur := yyVAL.stmt
  721. for _, elseif := range yyDollar[5].stmts {
  722. cur.(*ast.IfStmt).Else = []ast.Stmt{elseif}
  723. cur = elseif
  724. }
  725. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  726. yyVAL.stmt.SetLastLine(yyDollar[6].token.Pos.Line)
  727. }
  728. case 14:
  729. yyDollar = yyS[yypt-8 : yypt+1]
  730. //line parser.go.y:147
  731. {
  732. yyVAL.stmt = &ast.IfStmt{Condition: yyDollar[2].expr, Then: yyDollar[4].stmts}
  733. cur := yyVAL.stmt
  734. for _, elseif := range yyDollar[5].stmts {
  735. cur.(*ast.IfStmt).Else = []ast.Stmt{elseif}
  736. cur = elseif
  737. }
  738. cur.(*ast.IfStmt).Else = yyDollar[7].stmts
  739. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  740. yyVAL.stmt.SetLastLine(yyDollar[8].token.Pos.Line)
  741. }
  742. case 15:
  743. yyDollar = yyS[yypt-9 : yypt+1]
  744. //line parser.go.y:158
  745. {
  746. yyVAL.stmt = &ast.NumberForStmt{Name: yyDollar[2].token.Str, Init: yyDollar[4].expr, Limit: yyDollar[6].expr, Stmts: yyDollar[8].stmts}
  747. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  748. yyVAL.stmt.SetLastLine(yyDollar[9].token.Pos.Line)
  749. }
  750. case 16:
  751. yyDollar = yyS[yypt-11 : yypt+1]
  752. //line parser.go.y:163
  753. {
  754. yyVAL.stmt = &ast.NumberForStmt{Name: yyDollar[2].token.Str, Init: yyDollar[4].expr, Limit: yyDollar[6].expr, Step: yyDollar[8].expr, Stmts: yyDollar[10].stmts}
  755. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  756. yyVAL.stmt.SetLastLine(yyDollar[11].token.Pos.Line)
  757. }
  758. case 17:
  759. yyDollar = yyS[yypt-7 : yypt+1]
  760. //line parser.go.y:168
  761. {
  762. yyVAL.stmt = &ast.GenericForStmt{Names: yyDollar[2].namelist, Exprs: yyDollar[4].exprlist, Stmts: yyDollar[6].stmts}
  763. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  764. yyVAL.stmt.SetLastLine(yyDollar[7].token.Pos.Line)
  765. }
  766. case 18:
  767. yyDollar = yyS[yypt-3 : yypt+1]
  768. //line parser.go.y:173
  769. {
  770. yyVAL.stmt = &ast.FuncDefStmt{Name: yyDollar[2].funcname, Func: yyDollar[3].funcexpr}
  771. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  772. yyVAL.stmt.SetLastLine(yyDollar[3].funcexpr.LastLine())
  773. }
  774. case 19:
  775. yyDollar = yyS[yypt-4 : yypt+1]
  776. //line parser.go.y:178
  777. {
  778. yyVAL.stmt = &ast.LocalAssignStmt{Names: []string{yyDollar[3].token.Str}, Exprs: []ast.Expr{yyDollar[4].funcexpr}}
  779. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  780. yyVAL.stmt.SetLastLine(yyDollar[4].funcexpr.LastLine())
  781. }
  782. case 20:
  783. yyDollar = yyS[yypt-4 : yypt+1]
  784. //line parser.go.y:183
  785. {
  786. yyVAL.stmt = &ast.LocalAssignStmt{Names: yyDollar[2].namelist, Exprs: yyDollar[4].exprlist}
  787. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  788. }
  789. case 21:
  790. yyDollar = yyS[yypt-2 : yypt+1]
  791. //line parser.go.y:187
  792. {
  793. yyVAL.stmt = &ast.LocalAssignStmt{Names: yyDollar[2].namelist, Exprs: []ast.Expr{}}
  794. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  795. }
  796. case 22:
  797. yyDollar = yyS[yypt-3 : yypt+1]
  798. //line parser.go.y:191
  799. {
  800. yyVAL.stmt = &ast.LabelStmt{Name: yyDollar[2].token.Str}
  801. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  802. }
  803. case 23:
  804. yyDollar = yyS[yypt-2 : yypt+1]
  805. //line parser.go.y:195
  806. {
  807. yyVAL.stmt = &ast.GotoStmt{Label: yyDollar[2].token.Str}
  808. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  809. }
  810. case 24:
  811. yyDollar = yyS[yypt-0 : yypt+1]
  812. //line parser.go.y:201
  813. {
  814. yyVAL.stmts = []ast.Stmt{}
  815. }
  816. case 25:
  817. yyDollar = yyS[yypt-5 : yypt+1]
  818. //line parser.go.y:204
  819. {
  820. yyVAL.stmts = append(yyDollar[1].stmts, &ast.IfStmt{Condition: yyDollar[3].expr, Then: yyDollar[5].stmts})
  821. yyVAL.stmts[len(yyVAL.stmts)-1].SetLine(yyDollar[2].token.Pos.Line)
  822. }
  823. case 26:
  824. yyDollar = yyS[yypt-1 : yypt+1]
  825. //line parser.go.y:210
  826. {
  827. yyVAL.stmt = &ast.ReturnStmt{Exprs: nil}
  828. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  829. }
  830. case 27:
  831. yyDollar = yyS[yypt-2 : yypt+1]
  832. //line parser.go.y:214
  833. {
  834. yyVAL.stmt = &ast.ReturnStmt{Exprs: yyDollar[2].exprlist}
  835. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  836. }
  837. case 28:
  838. yyDollar = yyS[yypt-1 : yypt+1]
  839. //line parser.go.y:218
  840. {
  841. yyVAL.stmt = &ast.BreakStmt{}
  842. yyVAL.stmt.SetLine(yyDollar[1].token.Pos.Line)
  843. }
  844. case 29:
  845. yyDollar = yyS[yypt-1 : yypt+1]
  846. //line parser.go.y:224
  847. {
  848. yyVAL.funcname = yyDollar[1].funcname
  849. }
  850. case 30:
  851. yyDollar = yyS[yypt-3 : yypt+1]
  852. //line parser.go.y:227
  853. {
  854. yyVAL.funcname = &ast.FuncName{Func: nil, Receiver: yyDollar[1].funcname.Func, Method: yyDollar[3].token.Str}
  855. }
  856. case 31:
  857. yyDollar = yyS[yypt-1 : yypt+1]
  858. //line parser.go.y:232
  859. {
  860. yyVAL.funcname = &ast.FuncName{Func: &ast.IdentExpr{Value: yyDollar[1].token.Str}}
  861. yyVAL.funcname.Func.SetLine(yyDollar[1].token.Pos.Line)
  862. }
  863. case 32:
  864. yyDollar = yyS[yypt-3 : yypt+1]
  865. //line parser.go.y:236
  866. {
  867. key := &ast.StringExpr{Value: yyDollar[3].token.Str}
  868. key.SetLine(yyDollar[3].token.Pos.Line)
  869. fn := &ast.AttrGetExpr{Object: yyDollar[1].funcname.Func, Key: key}
  870. fn.SetLine(yyDollar[3].token.Pos.Line)
  871. yyVAL.funcname = &ast.FuncName{Func: fn}
  872. }
  873. case 33:
  874. yyDollar = yyS[yypt-1 : yypt+1]
  875. //line parser.go.y:245
  876. {
  877. yyVAL.exprlist = []ast.Expr{yyDollar[1].expr}
  878. }
  879. case 34:
  880. yyDollar = yyS[yypt-3 : yypt+1]
  881. //line parser.go.y:248
  882. {
  883. yyVAL.exprlist = append(yyDollar[1].exprlist, yyDollar[3].expr)
  884. }
  885. case 35:
  886. yyDollar = yyS[yypt-1 : yypt+1]
  887. //line parser.go.y:253
  888. {
  889. yyVAL.expr = &ast.IdentExpr{Value: yyDollar[1].token.Str}
  890. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  891. }
  892. case 36:
  893. yyDollar = yyS[yypt-4 : yypt+1]
  894. //line parser.go.y:257
  895. {
  896. yyVAL.expr = &ast.AttrGetExpr{Object: yyDollar[1].expr, Key: yyDollar[3].expr}
  897. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  898. }
  899. case 37:
  900. yyDollar = yyS[yypt-3 : yypt+1]
  901. //line parser.go.y:261
  902. {
  903. key := &ast.StringExpr{Value: yyDollar[3].token.Str}
  904. key.SetLine(yyDollar[3].token.Pos.Line)
  905. yyVAL.expr = &ast.AttrGetExpr{Object: yyDollar[1].expr, Key: key}
  906. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  907. }
  908. case 38:
  909. yyDollar = yyS[yypt-1 : yypt+1]
  910. //line parser.go.y:269
  911. {
  912. yyVAL.namelist = []string{yyDollar[1].token.Str}
  913. }
  914. case 39:
  915. yyDollar = yyS[yypt-3 : yypt+1]
  916. //line parser.go.y:272
  917. {
  918. yyVAL.namelist = append(yyDollar[1].namelist, yyDollar[3].token.Str)
  919. }
  920. case 40:
  921. yyDollar = yyS[yypt-1 : yypt+1]
  922. //line parser.go.y:277
  923. {
  924. yyVAL.exprlist = []ast.Expr{yyDollar[1].expr}
  925. }
  926. case 41:
  927. yyDollar = yyS[yypt-3 : yypt+1]
  928. //line parser.go.y:280
  929. {
  930. yyVAL.exprlist = append(yyDollar[1].exprlist, yyDollar[3].expr)
  931. }
  932. case 42:
  933. yyDollar = yyS[yypt-1 : yypt+1]
  934. //line parser.go.y:285
  935. {
  936. yyVAL.expr = &ast.NilExpr{}
  937. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  938. }
  939. case 43:
  940. yyDollar = yyS[yypt-1 : yypt+1]
  941. //line parser.go.y:289
  942. {
  943. yyVAL.expr = &ast.FalseExpr{}
  944. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  945. }
  946. case 44:
  947. yyDollar = yyS[yypt-1 : yypt+1]
  948. //line parser.go.y:293
  949. {
  950. yyVAL.expr = &ast.TrueExpr{}
  951. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  952. }
  953. case 45:
  954. yyDollar = yyS[yypt-1 : yypt+1]
  955. //line parser.go.y:297
  956. {
  957. yyVAL.expr = &ast.NumberExpr{Value: yyDollar[1].token.Str}
  958. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  959. }
  960. case 46:
  961. yyDollar = yyS[yypt-1 : yypt+1]
  962. //line parser.go.y:301
  963. {
  964. yyVAL.expr = &ast.Comma3Expr{}
  965. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  966. }
  967. case 47:
  968. yyDollar = yyS[yypt-1 : yypt+1]
  969. //line parser.go.y:305
  970. {
  971. yyVAL.expr = yyDollar[1].expr
  972. }
  973. case 48:
  974. yyDollar = yyS[yypt-1 : yypt+1]
  975. //line parser.go.y:308
  976. {
  977. yyVAL.expr = yyDollar[1].expr
  978. }
  979. case 49:
  980. yyDollar = yyS[yypt-1 : yypt+1]
  981. //line parser.go.y:311
  982. {
  983. yyVAL.expr = yyDollar[1].expr
  984. }
  985. case 50:
  986. yyDollar = yyS[yypt-1 : yypt+1]
  987. //line parser.go.y:314
  988. {
  989. yyVAL.expr = yyDollar[1].expr
  990. }
  991. case 51:
  992. yyDollar = yyS[yypt-3 : yypt+1]
  993. //line parser.go.y:317
  994. {
  995. yyVAL.expr = &ast.LogicalOpExpr{Lhs: yyDollar[1].expr, Operator: "or", Rhs: yyDollar[3].expr}
  996. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  997. }
  998. case 52:
  999. yyDollar = yyS[yypt-3 : yypt+1]
  1000. //line parser.go.y:321
  1001. {
  1002. yyVAL.expr = &ast.LogicalOpExpr{Lhs: yyDollar[1].expr, Operator: "and", Rhs: yyDollar[3].expr}
  1003. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1004. }
  1005. case 53:
  1006. yyDollar = yyS[yypt-3 : yypt+1]
  1007. //line parser.go.y:325
  1008. {
  1009. yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: ">", Rhs: yyDollar[3].expr}
  1010. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1011. }
  1012. case 54:
  1013. yyDollar = yyS[yypt-3 : yypt+1]
  1014. //line parser.go.y:329
  1015. {
  1016. yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "<", Rhs: yyDollar[3].expr}
  1017. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1018. }
  1019. case 55:
  1020. yyDollar = yyS[yypt-3 : yypt+1]
  1021. //line parser.go.y:333
  1022. {
  1023. yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: ">=", Rhs: yyDollar[3].expr}
  1024. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1025. }
  1026. case 56:
  1027. yyDollar = yyS[yypt-3 : yypt+1]
  1028. //line parser.go.y:337
  1029. {
  1030. yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "<=", Rhs: yyDollar[3].expr}
  1031. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1032. }
  1033. case 57:
  1034. yyDollar = yyS[yypt-3 : yypt+1]
  1035. //line parser.go.y:341
  1036. {
  1037. yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "==", Rhs: yyDollar[3].expr}
  1038. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1039. }
  1040. case 58:
  1041. yyDollar = yyS[yypt-3 : yypt+1]
  1042. //line parser.go.y:345
  1043. {
  1044. yyVAL.expr = &ast.RelationalOpExpr{Lhs: yyDollar[1].expr, Operator: "~=", Rhs: yyDollar[3].expr}
  1045. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1046. }
  1047. case 59:
  1048. yyDollar = yyS[yypt-3 : yypt+1]
  1049. //line parser.go.y:349
  1050. {
  1051. yyVAL.expr = &ast.StringConcatOpExpr{Lhs: yyDollar[1].expr, Rhs: yyDollar[3].expr}
  1052. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1053. }
  1054. case 60:
  1055. yyDollar = yyS[yypt-3 : yypt+1]
  1056. //line parser.go.y:353
  1057. {
  1058. yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "+", Rhs: yyDollar[3].expr}
  1059. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1060. }
  1061. case 61:
  1062. yyDollar = yyS[yypt-3 : yypt+1]
  1063. //line parser.go.y:357
  1064. {
  1065. yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "-", Rhs: yyDollar[3].expr}
  1066. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1067. }
  1068. case 62:
  1069. yyDollar = yyS[yypt-3 : yypt+1]
  1070. //line parser.go.y:361
  1071. {
  1072. yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "*", Rhs: yyDollar[3].expr}
  1073. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1074. }
  1075. case 63:
  1076. yyDollar = yyS[yypt-3 : yypt+1]
  1077. //line parser.go.y:365
  1078. {
  1079. yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "/", Rhs: yyDollar[3].expr}
  1080. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1081. }
  1082. case 64:
  1083. yyDollar = yyS[yypt-3 : yypt+1]
  1084. //line parser.go.y:369
  1085. {
  1086. yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "%", Rhs: yyDollar[3].expr}
  1087. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1088. }
  1089. case 65:
  1090. yyDollar = yyS[yypt-3 : yypt+1]
  1091. //line parser.go.y:373
  1092. {
  1093. yyVAL.expr = &ast.ArithmeticOpExpr{Lhs: yyDollar[1].expr, Operator: "^", Rhs: yyDollar[3].expr}
  1094. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1095. }
  1096. case 66:
  1097. yyDollar = yyS[yypt-2 : yypt+1]
  1098. //line parser.go.y:377
  1099. {
  1100. yyVAL.expr = &ast.UnaryMinusOpExpr{Expr: yyDollar[2].expr}
  1101. yyVAL.expr.SetLine(yyDollar[2].expr.Line())
  1102. }
  1103. case 67:
  1104. yyDollar = yyS[yypt-2 : yypt+1]
  1105. //line parser.go.y:381
  1106. {
  1107. yyVAL.expr = &ast.UnaryNotOpExpr{Expr: yyDollar[2].expr}
  1108. yyVAL.expr.SetLine(yyDollar[2].expr.Line())
  1109. }
  1110. case 68:
  1111. yyDollar = yyS[yypt-2 : yypt+1]
  1112. //line parser.go.y:385
  1113. {
  1114. yyVAL.expr = &ast.UnaryLenOpExpr{Expr: yyDollar[2].expr}
  1115. yyVAL.expr.SetLine(yyDollar[2].expr.Line())
  1116. }
  1117. case 69:
  1118. yyDollar = yyS[yypt-1 : yypt+1]
  1119. //line parser.go.y:391
  1120. {
  1121. yyVAL.expr = &ast.StringExpr{Value: yyDollar[1].token.Str}
  1122. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  1123. }
  1124. case 70:
  1125. yyDollar = yyS[yypt-1 : yypt+1]
  1126. //line parser.go.y:397
  1127. {
  1128. yyVAL.expr = yyDollar[1].expr
  1129. }
  1130. case 71:
  1131. yyDollar = yyS[yypt-1 : yypt+1]
  1132. //line parser.go.y:400
  1133. {
  1134. yyVAL.expr = yyDollar[1].expr
  1135. }
  1136. case 72:
  1137. yyDollar = yyS[yypt-1 : yypt+1]
  1138. //line parser.go.y:403
  1139. {
  1140. yyVAL.expr = yyDollar[1].expr
  1141. }
  1142. case 73:
  1143. yyDollar = yyS[yypt-3 : yypt+1]
  1144. //line parser.go.y:406
  1145. {
  1146. if ex, ok := yyDollar[2].expr.(*ast.Comma3Expr); ok {
  1147. ex.AdjustRet = true
  1148. }
  1149. yyVAL.expr = yyDollar[2].expr
  1150. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  1151. }
  1152. case 74:
  1153. yyDollar = yyS[yypt-3 : yypt+1]
  1154. //line parser.go.y:415
  1155. {
  1156. yyDollar[2].expr.(*ast.FuncCallExpr).AdjustRet = true
  1157. yyVAL.expr = yyDollar[2].expr
  1158. }
  1159. case 75:
  1160. yyDollar = yyS[yypt-2 : yypt+1]
  1161. //line parser.go.y:421
  1162. {
  1163. yyVAL.expr = &ast.FuncCallExpr{Func: yyDollar[1].expr, Args: yyDollar[2].exprlist}
  1164. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1165. }
  1166. case 76:
  1167. yyDollar = yyS[yypt-4 : yypt+1]
  1168. //line parser.go.y:425
  1169. {
  1170. yyVAL.expr = &ast.FuncCallExpr{Method: yyDollar[3].token.Str, Receiver: yyDollar[1].expr, Args: yyDollar[4].exprlist}
  1171. yyVAL.expr.SetLine(yyDollar[1].expr.Line())
  1172. }
  1173. case 77:
  1174. yyDollar = yyS[yypt-2 : yypt+1]
  1175. //line parser.go.y:431
  1176. {
  1177. if yylex.(*Lexer).PNewLine {
  1178. yylex.(*Lexer).TokenError(yyDollar[1].token, "ambiguous syntax (function call x new statement)")
  1179. }
  1180. yyVAL.exprlist = []ast.Expr{}
  1181. }
  1182. case 78:
  1183. yyDollar = yyS[yypt-3 : yypt+1]
  1184. //line parser.go.y:437
  1185. {
  1186. if yylex.(*Lexer).PNewLine {
  1187. yylex.(*Lexer).TokenError(yyDollar[1].token, "ambiguous syntax (function call x new statement)")
  1188. }
  1189. yyVAL.exprlist = yyDollar[2].exprlist
  1190. }
  1191. case 79:
  1192. yyDollar = yyS[yypt-1 : yypt+1]
  1193. //line parser.go.y:443
  1194. {
  1195. yyVAL.exprlist = []ast.Expr{yyDollar[1].expr}
  1196. }
  1197. case 80:
  1198. yyDollar = yyS[yypt-1 : yypt+1]
  1199. //line parser.go.y:446
  1200. {
  1201. yyVAL.exprlist = []ast.Expr{yyDollar[1].expr}
  1202. }
  1203. case 81:
  1204. yyDollar = yyS[yypt-2 : yypt+1]
  1205. //line parser.go.y:451
  1206. {
  1207. yyVAL.expr = &ast.FunctionExpr{ParList: yyDollar[2].funcexpr.ParList, Stmts: yyDollar[2].funcexpr.Stmts}
  1208. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  1209. yyVAL.expr.SetLastLine(yyDollar[2].funcexpr.LastLine())
  1210. }
  1211. case 82:
  1212. yyDollar = yyS[yypt-5 : yypt+1]
  1213. //line parser.go.y:458
  1214. {
  1215. yyVAL.funcexpr = &ast.FunctionExpr{ParList: yyDollar[2].parlist, Stmts: yyDollar[4].stmts}
  1216. yyVAL.funcexpr.SetLine(yyDollar[1].token.Pos.Line)
  1217. yyVAL.funcexpr.SetLastLine(yyDollar[5].token.Pos.Line)
  1218. }
  1219. case 83:
  1220. yyDollar = yyS[yypt-4 : yypt+1]
  1221. //line parser.go.y:463
  1222. {
  1223. yyVAL.funcexpr = &ast.FunctionExpr{ParList: &ast.ParList{HasVargs: false, Names: []string{}}, Stmts: yyDollar[3].stmts}
  1224. yyVAL.funcexpr.SetLine(yyDollar[1].token.Pos.Line)
  1225. yyVAL.funcexpr.SetLastLine(yyDollar[4].token.Pos.Line)
  1226. }
  1227. case 84:
  1228. yyDollar = yyS[yypt-1 : yypt+1]
  1229. //line parser.go.y:470
  1230. {
  1231. yyVAL.parlist = &ast.ParList{HasVargs: true, Names: []string{}}
  1232. }
  1233. case 85:
  1234. yyDollar = yyS[yypt-1 : yypt+1]
  1235. //line parser.go.y:473
  1236. {
  1237. yyVAL.parlist = &ast.ParList{HasVargs: false, Names: []string{}}
  1238. yyVAL.parlist.Names = append(yyVAL.parlist.Names, yyDollar[1].namelist...)
  1239. }
  1240. case 86:
  1241. yyDollar = yyS[yypt-3 : yypt+1]
  1242. //line parser.go.y:477
  1243. {
  1244. yyVAL.parlist = &ast.ParList{HasVargs: true, Names: []string{}}
  1245. yyVAL.parlist.Names = append(yyVAL.parlist.Names, yyDollar[1].namelist...)
  1246. }
  1247. case 87:
  1248. yyDollar = yyS[yypt-2 : yypt+1]
  1249. //line parser.go.y:484
  1250. {
  1251. yyVAL.expr = &ast.TableExpr{Fields: []*ast.Field{}}
  1252. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  1253. }
  1254. case 88:
  1255. yyDollar = yyS[yypt-3 : yypt+1]
  1256. //line parser.go.y:488
  1257. {
  1258. yyVAL.expr = &ast.TableExpr{Fields: yyDollar[2].fieldlist}
  1259. yyVAL.expr.SetLine(yyDollar[1].token.Pos.Line)
  1260. }
  1261. case 89:
  1262. yyDollar = yyS[yypt-1 : yypt+1]
  1263. //line parser.go.y:495
  1264. {
  1265. yyVAL.fieldlist = []*ast.Field{yyDollar[1].field}
  1266. }
  1267. case 90:
  1268. yyDollar = yyS[yypt-3 : yypt+1]
  1269. //line parser.go.y:498
  1270. {
  1271. yyVAL.fieldlist = append(yyDollar[1].fieldlist, yyDollar[3].field)
  1272. }
  1273. case 91:
  1274. yyDollar = yyS[yypt-2 : yypt+1]
  1275. //line parser.go.y:501
  1276. {
  1277. yyVAL.fieldlist = yyDollar[1].fieldlist
  1278. }
  1279. case 92:
  1280. yyDollar = yyS[yypt-3 : yypt+1]
  1281. //line parser.go.y:506
  1282. {
  1283. yyVAL.field = &ast.Field{Key: &ast.StringExpr{Value: yyDollar[1].token.Str}, Value: yyDollar[3].expr}
  1284. yyVAL.field.Key.SetLine(yyDollar[1].token.Pos.Line)
  1285. }
  1286. case 93:
  1287. yyDollar = yyS[yypt-5 : yypt+1]
  1288. //line parser.go.y:510
  1289. {
  1290. yyVAL.field = &ast.Field{Key: yyDollar[2].expr, Value: yyDollar[5].expr}
  1291. }
  1292. case 94:
  1293. yyDollar = yyS[yypt-1 : yypt+1]
  1294. //line parser.go.y:513
  1295. {
  1296. yyVAL.field = &ast.Field{Value: yyDollar[1].expr}
  1297. }
  1298. case 95:
  1299. yyDollar = yyS[yypt-1 : yypt+1]
  1300. //line parser.go.y:518
  1301. {
  1302. yyVAL.fieldsep = ","
  1303. }
  1304. case 96:
  1305. yyDollar = yyS[yypt-1 : yypt+1]
  1306. //line parser.go.y:521
  1307. {
  1308. yyVAL.fieldsep = ";"
  1309. }
  1310. }
  1311. goto yystack /* stack new state and value */
  1312. }