// This code was generated by the Gardens Point Parser Generator // Copyright (c) Wayne Kelly, QUT 2005-2008 // (see accompanying GPPGcopyright.rtf) // GPPG version 1.3.1.136 (2008-11-11) // Machine: PC // DateTime: 30.06.2009 22:50:24 // UserName: A // Input file // options: conflicts no-lines gplex conflicts using System; using System.Collections.Generic; using System.Text; using gppg; using System.IO; using PascalABCCompiler.SyntaxTree; using GPPGTools; namespace PascalABCCompiler.PythonABCParser { public enum Tokens { error=1,EOF=2,SEMICOLUMN=3,ENDLINE=4,kINDENT=5,kDEDENT=6, kIF=7,kELSE=8,kWHILE=9,kDEF=10,kFED=11,kRETURN=12, LPAREN=13,RPAREN=14,COLUMN=15,COLON=16,LSQUARE=17,RSQUARE=18, FUNCRETSYMB=19,DOT=20,ASSIGN=21,PLUS=22,MINUS=23,MULT=24, DIVIDE=25,AND=26,OR=27,NOT=28,LT=29,GT=30, EQ=31,NE=32,LE=33,GE=34,INTNUM=35,FLOATNUM=36, STRINGLITERAL=37,MULTILINESTRING=38,TRUECONST=39,FALSECONST=40,ID=41,bINT=42, bFLOAT=43,bSTR=44,bBOOL=45,UMINUS=46,LOWERTHENELSE=47}; public struct ValueType { public statement _statement; public addressed_value _addressed_value; public statement_list _statement_list; public const_node _const_node; public op_type_node _op_type_node; public token_info _token_info; public ident _ident; public named_type_reference _named_type_reference; public typed_parameters _typed_parametres; public formal_parameters _formal_parametres; public procedure_definition _procedure_definition; public declarations _declarations; public expression_list _expression_list; } // Abstract base class for GPLEX scanners public abstract class ScanBase : IScanner { private LexLocation __yylloc = new LexLocation(); public override LexLocation yylloc { get { return __yylloc; } set { __yylloc = value; } } protected virtual bool yywrap() { return true; } } public class Parser: ShiftReduceParser { // for fake dynamic typification List _var_def_statement_list = new List(); private Dictionary aliasses = null; protected override void Initialize() { this.errToken = (int)Tokens.error; this.eofToken = (int)Tokens.EOF; states=new State[123]; AddState(0,new State(new int[]{1,122,5,-4,10,-4},new int[]{-1,1,-8,3})); AddState(1,new State(new int[]{2,2})); AddState(2,new State(-1)); AddState(3,new State(new int[]{5,4,10,91},new int[]{-6,89,-7,90})); AddState(4,new State(new int[]{41,10,9,65,7,70,12,81,5,83,1,87,6,-22,3,-22,4,-22},new int[]{-14,5,-13,86,-11,80})); AddState(5,new State(new int[]{6,6,3,59,4,60},new int[]{-16,8})); AddState(6,new State(new int[]{1,7,2,-2})); AddState(7,new State(-21)); AddState(8,new State(new int[]{41,10,9,65,7,70,12,81,5,83,1,87,6,-22,3,-22,4,-22,11,-22},new int[]{-13,9,-11,80})); AddState(9,new State(-20)); AddState(10,new State(new int[]{21,11,13,62})); AddState(11,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,12})); AddState(12,new State(new int[]{22,13,23,15,24,17,25,19,26,21,27,23,29,25,30,27,33,29,34,31,31,33,32,35,6,-23,3,-23,4,-23,11,-23})); AddState(13,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,14})); AddState(14,new State(new int[]{22,-43,23,-43,24,17,25,19,26,21,27,-43,29,-43,30,-43,33,-43,34,-43,31,-43,32,-43,6,-43,3,-43,4,-43,11,-43,15,-43,14,-43,16,-43})); AddState(15,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,16})); AddState(16,new State(new int[]{22,-44,23,-44,24,17,25,19,26,21,27,-44,29,-44,30,-44,33,-44,34,-44,31,-44,32,-44,6,-44,3,-44,4,-44,11,-44,15,-44,14,-44,16,-44})); AddState(17,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,18})); AddState(18,new State(-45)); AddState(19,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,20})); AddState(20,new State(-46)); AddState(21,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,22})); AddState(22,new State(-47)); AddState(23,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,24})); AddState(24,new State(new int[]{22,-48,23,-48,24,17,25,19,26,21,27,-48,29,-48,30,-48,33,-48,34,-48,31,-48,32,-48,6,-48,3,-48,4,-48,11,-48,15,-48,14,-48,16,-48})); AddState(25,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,26})); AddState(26,new State(new int[]{22,13,23,15,24,17,25,19,26,21,27,23,29,-49,30,-49,33,-49,34,-49,31,-49,32,-49,6,-49,3,-49,4,-49,11,-49,15,-49,14,-49,16,-49})); AddState(27,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,28})); AddState(28,new State(new int[]{22,13,23,15,24,17,25,19,26,21,27,23,29,-50,30,-50,33,-50,34,-50,31,-50,32,-50,6,-50,3,-50,4,-50,11,-50,15,-50,14,-50,16,-50})); AddState(29,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,30})); AddState(30,new State(new int[]{22,13,23,15,24,17,25,19,26,21,27,23,29,-51,30,-51,33,-51,34,-51,31,-51,32,-51,6,-51,3,-51,4,-51,11,-51,15,-51,14,-51,16,-51})); AddState(31,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,32})); AddState(32,new State(new int[]{22,13,23,15,24,17,25,19,26,21,27,23,29,-52,30,-52,33,-52,34,-52,31,-52,32,-52,6,-52,3,-52,4,-52,11,-52,15,-52,14,-52,16,-52})); AddState(33,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,34})); AddState(34,new State(new int[]{22,13,23,15,24,17,25,19,26,21,27,23,29,-53,30,-53,33,-53,34,-53,31,-53,32,-53,6,-53,3,-53,4,-53,11,-53,15,-53,14,-53,16,-53})); AddState(35,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,36})); AddState(36,new State(new int[]{22,13,23,15,24,17,25,19,26,21,27,23,29,-54,30,-54,33,-54,34,-54,31,-54,32,-54,6,-54,3,-54,4,-54,11,-54,15,-54,14,-54,16,-54})); AddState(37,new State(-36)); AddState(38,new State(-37)); AddState(39,new State(-38)); AddState(40,new State(-39)); AddState(41,new State(new int[]{13,42,22,-40,23,-40,24,-40,25,-40,26,-40,27,-40,29,-40,30,-40,33,-40,34,-40,31,-40,32,-40,6,-40,3,-40,4,-40,11,-40,15,-40,14,-40,16,-40})); AddState(42,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57,14,-32},new int[]{-10,43,-9,45,-12,61})); AddState(43,new State(new int[]{14,44})); AddState(44,new State(-58)); AddState(45,new State(new int[]{15,46,14,-33})); AddState(46,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,47})); AddState(47,new State(new int[]{22,13,23,15,24,17,25,19,26,21,27,23,29,25,30,27,33,29,34,31,31,33,32,35,15,-35,14,-35})); AddState(48,new State(-41)); AddState(49,new State(-42)); AddState(50,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,51})); AddState(51,new State(-55)); AddState(52,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,53})); AddState(53,new State(-56)); AddState(54,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,55})); AddState(55,new State(new int[]{14,56,22,13,23,15,24,17,25,19,26,21,27,23,29,25,30,27,33,29,34,31,31,33,32,35})); AddState(56,new State(-57)); AddState(57,new State(new int[]{3,59,4,60},new int[]{-16,58})); AddState(58,new State(-59)); AddState(59,new State(-60)); AddState(60,new State(-61)); AddState(61,new State(new int[]{22,13,23,15,24,17,25,19,26,21,27,23,29,25,30,27,33,29,34,31,31,33,32,35,15,-34,14,-34})); AddState(62,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57,14,-32},new int[]{-10,63,-9,45,-12,61})); AddState(63,new State(new int[]{14,64})); AddState(64,new State(-27)); AddState(65,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,66})); AddState(66,new State(new int[]{16,67,22,13,23,15,24,17,25,19,26,21,27,23,29,25,30,27,33,29,34,31,31,33,32,35})); AddState(67,new State(new int[]{4,68})); AddState(68,new State(new int[]{41,10,9,65,7,70,12,81,5,83,1,87,6,-22,3,-22,4,-22,11,-22},new int[]{-13,69,-11,80})); AddState(69,new State(-24)); AddState(70,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,71})); AddState(71,new State(new int[]{16,72,22,13,23,15,24,17,25,19,26,21,27,23,29,25,30,27,33,29,34,31,31,33,32,35})); AddState(72,new State(new int[]{4,73})); AddState(73,new State(new int[]{41,10,9,65,7,70,12,81,5,83,1,87,4,-22},new int[]{-13,74,-11,80})); AddState(74,new State(new int[]{4,75})); AddState(75,new State(new int[]{8,76,6,-25,3,-25,4,-25,11,-25})); AddState(76,new State(new int[]{16,77})); AddState(77,new State(new int[]{4,78})); AddState(78,new State(new int[]{41,10,9,65,7,70,12,81,5,83,1,87,6,-22,3,-22,4,-22,11,-22},new int[]{-13,79,-11,80})); AddState(79,new State(-26)); AddState(80,new State(-28)); AddState(81,new State(new int[]{35,37,36,38,39,39,40,40,41,41,37,48,38,49,28,50,23,52,13,54,1,57},new int[]{-12,82})); AddState(82,new State(new int[]{22,13,23,15,24,17,25,19,26,21,27,23,29,25,30,27,33,29,34,31,31,33,32,35,6,-31,3,-31,4,-31,11,-31})); AddState(83,new State(new int[]{41,10,9,65,7,70,12,81,5,83,1,87,6,-22,3,-22,4,-22},new int[]{-14,84,-13,86,-11,80})); AddState(84,new State(new int[]{6,85,3,59,4,60},new int[]{-16,8})); AddState(85,new State(new int[]{1,7,6,-29,3,-29,4,-29,11,-29})); AddState(86,new State(-19)); AddState(87,new State(new int[]{2,88})); AddState(88,new State(-30)); AddState(89,new State(-5)); AddState(90,new State(-6)); AddState(91,new State(new int[]{41,92})); AddState(92,new State(new int[]{13,93})); AddState(93,new State(new int[]{41,116,1,120,14,-9},new int[]{-5,94,-4,113,-3,119})); AddState(94,new State(new int[]{14,95})); AddState(95,new State(new int[]{16,96,19,102})); AddState(96,new State(new int[]{3,59,4,60},new int[]{-16,97})); AddState(97,new State(new int[]{41,10,9,65,7,70,12,81,5,83,1,87,11,-22,6,-22,3,-22,4,-22},new int[]{-14,98,-13,86,-11,80})); AddState(98,new State(new int[]{11,99,6,101,3,59,4,60},new int[]{-16,8})); AddState(99,new State(new int[]{3,59,4,60},new int[]{-16,100})); AddState(100,new State(-8)); AddState(101,new State(new int[]{1,7})); AddState(102,new State(new int[]{42,109,43,110,44,111,45,112},new int[]{-2,103})); AddState(103,new State(new int[]{16,104})); AddState(104,new State(new int[]{3,59,4,60},new int[]{-16,105})); AddState(105,new State(new int[]{41,10,9,65,7,70,12,81,5,83,1,87,11,-22,6,-22,3,-22,4,-22},new int[]{-14,106,-13,86,-11,80})); AddState(106,new State(new int[]{11,107,6,101,3,59,4,60},new int[]{-16,8})); AddState(107,new State(new int[]{3,59,4,60},new int[]{-16,108})); AddState(108,new State(-7)); AddState(109,new State(-15)); AddState(110,new State(-16)); AddState(111,new State(-17)); AddState(112,new State(-18)); AddState(113,new State(new int[]{15,114,14,-10})); AddState(114,new State(new int[]{41,116},new int[]{-3,115})); AddState(115,new State(-12)); AddState(116,new State(new int[]{16,117})); AddState(117,new State(new int[]{42,109,43,110,44,111,45,112},new int[]{-2,118})); AddState(118,new State(-14)); AddState(119,new State(-11)); AddState(120,new State(new int[]{14,121})); AddState(121,new State(-13)); AddState(122,new State(-3)); rules=new Rule[62]; rules[1]=new Rule(-15, new int[]{-1,2}); rules[2]=new Rule(-1, new int[]{-8,5,-14,6}); rules[3]=new Rule(-1, new int[]{1}); rules[4]=new Rule(-8, new int[]{}); rules[5]=new Rule(-8, new int[]{-8,-6}); rules[6]=new Rule(-8, new int[]{-8,-7}); rules[7]=new Rule(-7, new int[]{10,41,13,-5,14,19,-2,16,-16,-14,11,-16}); rules[8]=new Rule(-6, new int[]{10,41,13,-5,14,16,-16,-14,11,-16}); rules[9]=new Rule(-5, new int[]{}); rules[10]=new Rule(-5, new int[]{-4}); rules[11]=new Rule(-4, new int[]{-3}); rules[12]=new Rule(-4, new int[]{-4,15,-3}); rules[13]=new Rule(-4, new int[]{1,14}); rules[14]=new Rule(-3, new int[]{41,16,-2}); rules[15]=new Rule(-2, new int[]{42}); rules[16]=new Rule(-2, new int[]{43}); rules[17]=new Rule(-2, new int[]{44}); rules[18]=new Rule(-2, new int[]{45}); rules[19]=new Rule(-14, new int[]{-13}); rules[20]=new Rule(-14, new int[]{-14,-16,-13}); rules[21]=new Rule(-14, new int[]{-14,6,1}); rules[22]=new Rule(-13, new int[]{}); rules[23]=new Rule(-13, new int[]{41,21,-12}); rules[24]=new Rule(-13, new int[]{9,-12,16,4,-13}); rules[25]=new Rule(-13, new int[]{7,-12,16,4,-13,4}); rules[26]=new Rule(-13, new int[]{7,-12,16,4,-13,4,8,16,4,-13}); rules[27]=new Rule(-13, new int[]{41,13,-10,14}); rules[28]=new Rule(-13, new int[]{-11}); rules[29]=new Rule(-13, new int[]{5,-14,6}); rules[30]=new Rule(-13, new int[]{1,2}); rules[31]=new Rule(-11, new int[]{12,-12}); rules[32]=new Rule(-10, new int[]{}); rules[33]=new Rule(-10, new int[]{-9}); rules[34]=new Rule(-9, new int[]{-12}); rules[35]=new Rule(-9, new int[]{-9,15,-12}); rules[36]=new Rule(-12, new int[]{35}); rules[37]=new Rule(-12, new int[]{36}); rules[38]=new Rule(-12, new int[]{39}); rules[39]=new Rule(-12, new int[]{40}); rules[40]=new Rule(-12, new int[]{41}); rules[41]=new Rule(-12, new int[]{37}); rules[42]=new Rule(-12, new int[]{38}); rules[43]=new Rule(-12, new int[]{-12,22,-12}); rules[44]=new Rule(-12, new int[]{-12,23,-12}); rules[45]=new Rule(-12, new int[]{-12,24,-12}); rules[46]=new Rule(-12, new int[]{-12,25,-12}); rules[47]=new Rule(-12, new int[]{-12,26,-12}); rules[48]=new Rule(-12, new int[]{-12,27,-12}); rules[49]=new Rule(-12, new int[]{-12,29,-12}); rules[50]=new Rule(-12, new int[]{-12,30,-12}); rules[51]=new Rule(-12, new int[]{-12,33,-12}); rules[52]=new Rule(-12, new int[]{-12,34,-12}); rules[53]=new Rule(-12, new int[]{-12,31,-12}); rules[54]=new Rule(-12, new int[]{-12,32,-12}); rules[55]=new Rule(-12, new int[]{28,-12}); rules[56]=new Rule(-12, new int[]{23,-12}); rules[57]=new Rule(-12, new int[]{13,-12,14}); rules[58]=new Rule(-12, new int[]{41,13,-10,14}); rules[59]=new Rule(-12, new int[]{1,-16}); rules[60]=new Rule(-16, new int[]{3}); rules[61]=new Rule(-16, new int[]{4}); nonTerminals = new string[] {"", "program", "builtintype", "formalparam", "formallist", "formalparams", "procdecl", "funcdecl", "decls", "exprlist", "factparams", "retstmt", "expr", "stmt", "liststmt", "$accept", "term", }; } protected override void DoAction(int action) { switch (action) { case 2: // program -> decls, kINDENT, liststmt, kDEDENT { //$1.source_context = PT.GetTokenSourceContext(@1); value_stack.array[value_stack.top-2]._statement_list.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); variable_definitions _variable_definitions = new variable_definitions(); foreach (var_def_statement vds in _var_def_statement_list) { _variable_definitions.var_definitions.Add(vds); } _var_def_statement_list.Clear(); declarations _declarations1; if(value_stack.array[value_stack.top-4]._declarations == null) _declarations1 = new declarations(); else _declarations1 = value_stack.array[value_stack.top-4]._declarations; _declarations1.defs.Add(_variable_definitions); //_declarations1.source_context = PT.GetTokenSourceContext(@1); // block _block; if(_declarations1.defs.Count > 0) _block = new block(_declarations1, value_stack.array[value_stack.top-2]._statement_list); else _block = new block(null, value_stack.array[value_stack.top-2]._statement_list); //_block.source_context = PT.GetTokenSourceContext(@1.Merge(@2)); // @$ GPPGParser.CompilationUnit = new program_module(null, null, _block, null); GPPGParser.CompilationUnit.Language = LanguageId.PascalABCNET; //GPPGParser.CompilationUnit.source_context = _block.source_context; // @$ } break; case 3: // program -> error { GPPGParser.CompilationUnit = new compilation_unit(); Errors.ErrorMsg err = new Errors.ErrorMsg(GPPGParser.current_file_name, PT.GetTokenSourceContext(yyloc), "PROGRAM_ERROR"); GPPGParser.errors.Add(err); } break; case 4: // decls -> /* empty */ { yyval._declarations = null; } break; case 5: // decls -> decls, procdecl { //if ($1 != null) $1.source_context = PT.GetTokenSourceContext(@1); //$2.source_context = PT.GetTokenSourceContext(@2); declarations _declarations1; if (value_stack.array[value_stack.top-2]._declarations != null) { _declarations1 = value_stack.array[value_stack.top-2]._declarations; _declarations1.defs.Add(value_stack.array[value_stack.top-1]._procedure_definition); } else { _declarations1 = new declarations(); _declarations1.defs.Add(value_stack.array[value_stack.top-1]._procedure_definition); } yyval._declarations = _declarations1; //$$.source_context = PT.GetTokenSourceContext(@2); // !!! } break; case 6: // decls -> decls, funcdecl { declarations _declarations1; if (value_stack.array[value_stack.top-2]._declarations != null) { _declarations1 = value_stack.array[value_stack.top-2]._declarations; _declarations1.defs.Add(value_stack.array[value_stack.top-1]._procedure_definition); } else { _declarations1 = new declarations(); _declarations1.defs.Add(value_stack.array[value_stack.top-1]._procedure_definition); } yyval._declarations = _declarations1; } break; case 7: // funcdecl -> kDEF, ID, LPAREN, formalparams, RPAREN, FUNCRETSYMB, builtintype, // COLON, term, liststmt, kFED, term {// 1 2 3 4 5 6 7 8 9 10 11 12 value_stack.array[value_stack.top-12]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-12]); value_stack.array[value_stack.top-11]._ident.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-11]); value_stack.array[value_stack.top-10]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-10]); PT.AssignSourceContext(value_stack.array[value_stack.top-9]._formal_parametres, location_stack.array[location_stack.top-9]); value_stack.array[value_stack.top-8]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-8]); value_stack.array[value_stack.top-7]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-7]); value_stack.array[value_stack.top-6]._named_type_reference.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-6]); value_stack.array[value_stack.top-5]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-5]); value_stack.array[value_stack.top-3]._statement_list.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); method_name _method_name = new method_name(null, value_stack.array[value_stack.top-11]._ident, null); function_header _function_header = new function_header(value_stack.array[value_stack.top-6]._named_type_reference); _function_header.of_object = false; _function_header.name = _method_name; _function_header.parameters = value_stack.array[value_stack.top-9]._formal_parametres; _method_name.source_context = value_stack.array[value_stack.top-11]._ident.source_context; _function_header.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-12].Merge(location_stack.array[location_stack.top-5])); // HACK: aftereffects fake dynamic typification if(value_stack.array[value_stack.top-9]._formal_parametres != null) foreach (typed_parameters tp in value_stack.array[value_stack.top-9]._formal_parametres.params_list) { bool HaveIdent = false; var_def_statement v = new var_def_statement(); foreach (var_def_statement vds in _var_def_statement_list) { if(tp.idents.idents[0].name == vds.vars.idents[0].name) { HaveIdent = true; v = vds; break; } } if (HaveIdent) _var_def_statement_list.Remove(v); } variable_definitions _variable_definitions = new variable_definitions(); foreach (var_def_statement vds in _var_def_statement_list) { _variable_definitions.var_definitions.Add(vds); } // end hack declarations _declarations1 = new declarations(); _declarations1.defs.Add(_variable_definitions); _declarations1.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-9]); // formalparams block _block; if(_declarations1.defs.Count > 0) _block = new block(_declarations1, value_stack.array[value_stack.top-3]._statement_list); else _block = new block(null, value_stack.array[value_stack.top-3]._statement_list); _var_def_statement_list.Clear(); _block.source_context = PT.GetTokenSourceContext(yyloc); procedure_definition _procedure_definition = new procedure_definition(_function_header, _block); yyval._procedure_definition = _procedure_definition; yyval._procedure_definition.source_context = PT.GetTokenSourceContext(yyloc); } break; case 8: // procdecl -> kDEF, ID, LPAREN, formalparams, RPAREN, COLON, term, liststmt, kFED, // term {// 1 2 3 4 5 6 7 8 9 value_stack.array[value_stack.top-10]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-10]); value_stack.array[value_stack.top-9]._ident.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-9]); value_stack.array[value_stack.top-8]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-8]); PT.AssignSourceContext(value_stack.array[value_stack.top-7]._formal_parametres, location_stack.array[location_stack.top-7]); value_stack.array[value_stack.top-6]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-6]); value_stack.array[value_stack.top-5]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-5]); value_stack.array[value_stack.top-3]._statement_list.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); method_name _method_name = new method_name(null, value_stack.array[value_stack.top-9]._ident, null); procedure_header _procedure_header = new procedure_header(value_stack.array[value_stack.top-7]._formal_parametres, null, _method_name, false, false, null, null); _method_name.source_context = value_stack.array[value_stack.top-9]._ident.source_context; _procedure_header.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-10].Merge(location_stack.array[location_stack.top-5])); // sum of lex locations 1..6 // HACK: aftereffects fake dynamic typification if(value_stack.array[value_stack.top-7]._formal_parametres != null) foreach (typed_parameters tp in value_stack.array[value_stack.top-7]._formal_parametres.params_list) { bool HaveIdent = false; var_def_statement v = new var_def_statement(); foreach (var_def_statement vds in _var_def_statement_list) { if(tp.idents.idents[0].name == vds.vars.idents[0].name) { HaveIdent = true; v = vds; break; } } if (HaveIdent) _var_def_statement_list.Remove(v); } variable_definitions _variable_definitions = new variable_definitions(); foreach (var_def_statement vds in _var_def_statement_list) { _variable_definitions.var_definitions.Add(vds); } // end hack declarations _declarations1 = new declarations(); _declarations1.defs.Add(_variable_definitions); _declarations1.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-7]); // formalparams block _block; if(_declarations1.defs.Count > 0) _block = new block(_declarations1, value_stack.array[value_stack.top-3]._statement_list); else _block = new block(null, value_stack.array[value_stack.top-3]._statement_list); _var_def_statement_list.Clear(); _block.source_context = PT.GetTokenSourceContext(yyloc); procedure_definition _procedure_definition = new procedure_definition(_procedure_header, _block); yyval._procedure_definition = _procedure_definition; yyval._procedure_definition.source_context = PT.GetTokenSourceContext(yyloc); } break; case 9: // formalparams -> /* empty */ { yyval._formal_parametres = null; } break; case 10: // formalparams -> formallist { value_stack.array[value_stack.top-1]._formal_parametres.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._formal_parametres = value_stack.array[value_stack.top-1]._formal_parametres; yyval._formal_parametres.source_context = PT.GetTokenSourceContext(yyloc); } break; case 11: // formallist -> formalparam { value_stack.array[value_stack.top-1]._typed_parametres.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); formal_parameters _formal_parametres = new formal_parameters(); _formal_parametres.params_list.Add(value_stack.array[value_stack.top-1]._typed_parametres); yyval._formal_parametres = _formal_parametres; yyval._formal_parametres.source_context = PT.GetTokenSourceContext(yyloc); } break; case 12: // formallist -> formallist, COLUMN, formalparam { value_stack.array[value_stack.top-3]._formal_parametres.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._typed_parametres.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); formal_parameters _formal_parametres = value_stack.array[value_stack.top-3]._formal_parametres; _formal_parametres.params_list.Add(value_stack.array[value_stack.top-1]._typed_parametres); yyval._formal_parametres = _formal_parametres; yyval._formal_parametres.source_context = PT.GetTokenSourceContext(yyloc); } break; case 13: // formallist -> error, RPAREN { GPPGParser.CompilationUnit = new compilation_unit(); Errors.ErrorMsg err = new Errors.ErrorMsg(GPPGParser.current_file_name, PT.GetTokenSourceContext(yyloc), "FORMALLIST_ERROR"); GPPGParser.errors.Add(err); } break; case 14: // formalparam -> ID, COLON, builtintype { value_stack.array[value_stack.top-3]._ident.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._named_type_reference.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); ident_list _ident_list = new ident_list(); _ident_list.idents.Add(value_stack.array[value_stack.top-3]._ident); named_type_reference _named_type_reference = value_stack.array[value_stack.top-1]._named_type_reference; typed_parameters _typed_parametres = new typed_parameters(_ident_list, _named_type_reference, parametr_kind.none, null); yyval._typed_parametres = _typed_parametres; yyval._typed_parametres.source_context = PT.GetTokenSourceContext(yyloc); } break; case 15: // builtintype -> bINT { value_stack.array[value_stack.top-1]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); named_type_reference _named_type_reference = new named_type_reference(); _named_type_reference.names.Add(new ident("integer")); yyval._named_type_reference = _named_type_reference; yyval._named_type_reference.source_context = PT.GetTokenSourceContext(yyloc); } break; case 16: // builtintype -> bFLOAT { value_stack.array[value_stack.top-1]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); named_type_reference _named_type_reference = new named_type_reference(); _named_type_reference.names.Add(new ident("real")); yyval._named_type_reference = _named_type_reference; yyval._named_type_reference.source_context = PT.GetTokenSourceContext(yyloc); } break; case 17: // builtintype -> bSTR { value_stack.array[value_stack.top-1]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); named_type_reference _named_type_reference = new named_type_reference(); _named_type_reference.names.Add(new ident("string")); yyval._named_type_reference = _named_type_reference; yyval._named_type_reference.source_context = PT.GetTokenSourceContext(yyloc); } break; case 18: // builtintype -> bBOOL { value_stack.array[value_stack.top-1]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); named_type_reference _named_type_reference = new named_type_reference(); _named_type_reference.names.Add(new ident("boolean")); yyval._named_type_reference = _named_type_reference; yyval._named_type_reference.source_context = PT.GetTokenSourceContext(yyloc); } break; case 19: // liststmt -> stmt { value_stack.array[value_stack.top-1]._statement.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); statement_list _sl = new statement_list(); _sl.subnodes.Add(value_stack.array[value_stack.top-1]._statement); yyval._statement_list = _sl; yyval._statement_list.source_context = PT.GetTokenSourceContext(yyloc); } break; case 20: // liststmt -> liststmt, term, stmt { value_stack.array[value_stack.top-3]._statement_list.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-1]._statement.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); statement_list _sl = value_stack.array[value_stack.top-3]._statement_list; _sl.subnodes.Add(value_stack.array[value_stack.top-1]._statement); yyval._statement_list = _sl; yyval._statement_list.source_context = PT.GetTokenSourceContext(yyloc); } break; case 21: // liststmt -> liststmt, kDEDENT, error { GPPGParser.CompilationUnit = new compilation_unit(); Errors.ErrorMsg err = new Errors.ErrorMsg(GPPGParser.current_file_name, PT.GetTokenSourceContext(yyloc), "err in liststmt"); GPPGParser.errors.Add(err); } break; case 22: // stmt -> /* empty */ { yyval._statement = new empty_statement(); yyval._statement.source_context = PT.GetTokenSourceContext(yyloc); } break; case 23: // stmt -> ID, ASSIGN, expr { value_stack.array[value_stack.top-3]._ident.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); // HACK: fake dynamic typification ident_list _ident_list = new ident_list(); _ident_list.idents.Add(value_stack.array[value_stack.top-3]._ident); var_def_statement _var_def_statement = new var_def_statement(_ident_list, null, value_stack.array[value_stack.top-1]._addressed_value, definition_attribute.None, false); bool HaveIdent = false; foreach (var_def_statement vds in _var_def_statement_list) { if(vds.vars.idents[0].name == value_stack.array[value_stack.top-3]._ident.name) { HaveIdent = true; break; } } if(!HaveIdent) _var_def_statement_list.Add(_var_def_statement); // end hack yyval._statement = new assign(value_stack.array[value_stack.top-3]._ident, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._statement.source_context = PT.GetTokenSourceContext(yyloc); } break; case 24: // stmt -> kWHILE, expr, COLON, ENDLINE, stmt { value_stack.array[value_stack.top-5]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-5]); value_stack.array[value_stack.top-4]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-4]); value_stack.array[value_stack.top-3]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-1]._statement.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._statement = new while_node(value_stack.array[value_stack.top-4]._addressed_value, value_stack.array[value_stack.top-1]._statement, WhileCycleType.While); yyval._statement.source_context = PT.GetTokenSourceContext(yyloc); } break; case 25: // stmt -> kIF, expr, COLON, ENDLINE, stmt, ENDLINE { value_stack.array[value_stack.top-6]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-6]); value_stack.array[value_stack.top-5]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-5]); value_stack.array[value_stack.top-4]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-4]); value_stack.array[value_stack.top-2]._statement.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); yyval._statement = new if_node(value_stack.array[value_stack.top-5]._addressed_value, value_stack.array[value_stack.top-2]._statement, null); yyval._statement.source_context = PT.GetTokenSourceContext(yyloc); } break; case 26: // stmt -> kIF, expr, COLON, ENDLINE, stmt, ENDLINE, kELSE, COLON, ENDLINE, stmt { value_stack.array[value_stack.top-10]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-10]); value_stack.array[value_stack.top-9]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-9]); value_stack.array[value_stack.top-8]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-8]); value_stack.array[value_stack.top-6]._statement.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-6]); value_stack.array[value_stack.top-1]._statement.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._statement = new if_node(value_stack.array[value_stack.top-9]._addressed_value, value_stack.array[value_stack.top-6]._statement, value_stack.array[value_stack.top-1]._statement); yyval._statement.source_context = PT.GetTokenSourceContext(yyloc); } break; case 27: // stmt -> ID, LPAREN, factparams, RPAREN { value_stack.array[value_stack.top-4]._ident.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-4]); value_stack.array[value_stack.top-3]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); PT.AssignSourceContext(value_stack.array[value_stack.top-2]._expression_list, location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); procedure_call _procedure_call = new procedure_call(); method_call _method_call; if(value_stack.array[value_stack.top-2]._expression_list != null) _method_call = new method_call(value_stack.array[value_stack.top-2]._expression_list); else _method_call = new method_call(); if (ParserHelper.builtins.ContainsKey(value_stack.array[value_stack.top-4]._ident.name)) { _method_call.dereferencing_value = new ident(ParserHelper.builtins[value_stack.array[value_stack.top-4]._ident.name]); } else { _method_call.dereferencing_value = value_stack.array[value_stack.top-4]._ident; } _method_call.source_context = value_stack.array[value_stack.top-4]._ident.source_context; _procedure_call.func_name = _method_call; yyval._statement = _procedure_call; yyval._statement.source_context = PT.GetTokenSourceContext(yyloc); } break; case 28: // stmt -> retstmt { value_stack.array[value_stack.top-1]._statement.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._statement = value_stack.array[value_stack.top-1]._statement; yyval._statement.source_context = PT.GetTokenSourceContext(yyloc); } break; case 29: // stmt -> kINDENT, liststmt, kDEDENT { value_stack.array[value_stack.top-3]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._statement_list.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._statement = value_stack.array[value_stack.top-2]._statement_list; yyval._statement.source_context = PT.GetTokenSourceContext(yyloc); } break; case 30: // stmt -> error, EOF { GPPGParser.CompilationUnit = new compilation_unit(); Errors.ErrorMsg err = new Errors.ErrorMsg(GPPGParser.current_file_name, PT.GetTokenSourceContext(yyloc), "STATEMENT_EXPECTED"); GPPGParser.errors.Add(err); } break; case 31: // retstmt -> kRETURN, expr { value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); ident id = PT.create_directive_name("result", location_stack.array[location_stack.top-2]); yyval._statement = new assign(id, value_stack.array[value_stack.top-1]._addressed_value, Operators.Assignment); yyval._statement.source_context = PT.GetTokenSourceContext(yyloc); } break; case 32: // factparams -> /* empty */ { yyval._expression_list = null; } break; case 33: // factparams -> exprlist { value_stack.array[value_stack.top-1]._expression_list.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._expression_list = value_stack.array[value_stack.top-1]._expression_list; yyval._expression_list.source_context = PT.GetTokenSourceContext(yyloc); } break; case 34: // exprlist -> expr { value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); expression_list _expression_list = new expression_list(); _expression_list.expressions.Add(value_stack.array[value_stack.top-1]._addressed_value); yyval._expression_list = _expression_list; yyval._expression_list.source_context = PT.GetTokenSourceContext(yyloc); } break; case 35: // exprlist -> exprlist, COLUMN, expr { value_stack.array[value_stack.top-3]._expression_list.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); expression_list _expression_list = value_stack.array[value_stack.top-3]._expression_list; _expression_list.expressions.Add(value_stack.array[value_stack.top-1]._addressed_value); yyval._expression_list = _expression_list; yyval._expression_list.source_context = PT.GetTokenSourceContext(yyloc); } break; case 36: // expr -> INTNUM { value_stack.array[value_stack.top-1]._const_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = value_stack.array[value_stack.top-1]._const_node; yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 37: // expr -> FLOATNUM { value_stack.array[value_stack.top-1]._const_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = value_stack.array[value_stack.top-1]._const_node; yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 38: // expr -> TRUECONST { value_stack.array[value_stack.top-1]._const_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = value_stack.array[value_stack.top-1]._const_node; yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 39: // expr -> FALSECONST { value_stack.array[value_stack.top-1]._const_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = value_stack.array[value_stack.top-1]._const_node; yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 40: // expr -> ID { value_stack.array[value_stack.top-1]._ident.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = value_stack.array[value_stack.top-1]._ident; yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 41: // expr -> STRINGLITERAL { value_stack.array[value_stack.top-1]._const_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = value_stack.array[value_stack.top-1]._const_node; yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 42: // expr -> MULTILINESTRING { value_stack.array[value_stack.top-1]._const_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = value_stack.array[value_stack.top-1]._const_node; yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 43: // expr -> expr, PLUS, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 44: // expr -> expr, MINUS, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 45: // expr -> expr, MULT, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 46: // expr -> expr, DIVIDE, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 47: // expr -> expr, AND, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 48: // expr -> expr, OR, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 49: // expr -> expr, LT, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 50: // expr -> expr, GT, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 51: // expr -> expr, LE, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 52: // expr -> expr, GE, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 53: // expr -> expr, EQ, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 54: // expr -> expr, NE, expr { value_stack.array[value_stack.top-3]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new bin_expr(value_stack.array[value_stack.top-3]._addressed_value, value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 55: // expr -> NOT, expr { value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new un_expr(value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 56: // expr -> MINUS, expr { value_stack.array[value_stack.top-2]._op_type_node.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); yyval._addressed_value = new un_expr(value_stack.array[value_stack.top-1]._addressed_value, value_stack.array[value_stack.top-2]._op_type_node.type); yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 57: // expr -> LPAREN, expr, RPAREN { value_stack.array[value_stack.top-2]._addressed_value.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-2]); yyval._addressed_value = value_stack.array[value_stack.top-2]._addressed_value; yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 58: // expr -> ID, LPAREN, factparams, RPAREN { value_stack.array[value_stack.top-4]._ident.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-4]); value_stack.array[value_stack.top-3]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-3]); PT.AssignSourceContext(value_stack.array[value_stack.top-2]._expression_list, location_stack.array[location_stack.top-2]); value_stack.array[value_stack.top-1]._token_info.source_context = PT.GetTokenSourceContext(location_stack.array[location_stack.top-1]); method_call _method_call; if(value_stack.array[value_stack.top-2]._expression_list != null) _method_call = new method_call(value_stack.array[value_stack.top-2]._expression_list); else _method_call = new method_call(); if (ParserHelper.builtins.ContainsKey(value_stack.array[value_stack.top-4]._ident.name)) { _method_call.dereferencing_value = new ident(ParserHelper.builtins[value_stack.array[value_stack.top-4]._ident.name]); } else { _method_call.dereferencing_value = value_stack.array[value_stack.top-4]._ident; } _method_call.dereferencing_value.source_context = value_stack.array[value_stack.top-4]._ident.source_context; yyval._addressed_value = _method_call; yyval._addressed_value.source_context = PT.GetTokenSourceContext(yyloc); } break; case 59: // expr -> error, term { GPPGParser.CompilationUnit = new compilation_unit(); Errors.ErrorMsg err = new Errors.ErrorMsg(GPPGParser.current_file_name, PT.GetTokenSourceContext(yyloc), "EXPRESSION_EXPECTED"); GPPGParser.errors.Add(err); } break; } } protected override string TerminalToString(int terminal) { if (aliasses != null && aliasses.ContainsKey(terminal)) return aliasses[terminal]; else if (((Tokens)terminal).ToString() != terminal.ToString()) return ((Tokens)terminal).ToString(); else return CharToString((char)terminal); } PythonParserTools PT = new PythonParserTools(); class ParserHelper { public static Dictionary builtins; static ParserHelper() { builtins = new Dictionary(); builtins.Add("print", "writeln"); builtins.Add("input", "readln"); } } } }