public MmlLine Clone() { var loc = new MmlLineInfo (Location.File, Location.LineNumber); loc.LinePosition = Location.LinePosition; return new MmlLine (loc, Text); }
public MmlMacroDefinition(string name, IList<int> targetTracks, MmlLineInfo location) { Name = name; TargetTracks = targetTracks; Location = location; Tokens = new List<MmlToken> (); }
public Exception MmlError(MmlLineInfo location, string msg) { return new MmlException (msg, location); }
public MmlLine(MmlLineInfo location, string text) { Location = location; Text = text; }
static string FormatMessage(string message, MmlLineInfo location) { if (location == null) return message; return String.Format ("{0} ({1} line {2} column {3})", message, location.File, location.LineNumber, location.LinePosition); }
public MmlVariableDefinition(string name, MmlLineInfo location) { Name = name; Location = location; DefaultValueTokens = new List<MmlToken> (); }
public MmlException(string message, MmlLineInfo location, Exception innerException) : base(FormatMessage (message, location), innerException) { }
public MmlException(string message, MmlLineInfo location) : this(message, location, null) { }
public TokenStream(IList<MmlToken> source, MmlLineInfo definitionLocation) { Source = source; DefinitionLocation = definitionLocation; }
public MmlOperationUse(string name, MmlLineInfo location) { if (name == null) throw new ArgumentNullException ("name"); Name = name; Location = location; Arguments = new List<MmlValueExpr> (); }
/** the generated parser. Maintains a state and a value stack, currently with fixed maximum size. @param yyLex scanner. @return result of the last reduction, if any. @throws yyException on irrecoverable parse error. */ internal Object yyparse (yyParser.yyInput yyLex) { if (yyMax <= 0) yyMax = 256; // initial size int yyState = 0; // state stack ptr int [] yyStates; // state stack yyVal = null; yyToken = -1; int yyErrorFlag = 0; // #tks to shift if (use_global_stacks && global_yyStates != null) { yyVals = global_yyVals; yyStates = global_yyStates; } else { yyVals = new object [yyMax]; yyStates = new int [yyMax]; if (use_global_stacks) { global_yyVals = yyVals; global_yyStates = yyStates; } } /*yyLoop:*/ for (yyTop = 0;; ++ yyTop) { if (yyTop >= yyStates.Length) { // dynamically increase global::System.Array.Resize (ref yyStates, yyStates.Length+yyMax); global::System.Array.Resize (ref yyVals, yyVals.Length+yyMax); } yyStates[yyTop] = yyState; yyVals[yyTop] = yyVal; if (debug != null) debug.push(yyState, yyVal); /*yyDiscarded:*/ while (true) { // discarding a token does not change stack int yyN; if ((yyN = yyDefRed[yyState]) == 0) { // else [default] reduce (yyN) if (yyToken < 0) { yyToken = yyLex.advance() ? yyLex.token() : 0; if (debug != null) debug.lex(yyState, yyToken, yyname(yyToken), yyLex.value()); } if ((yyN = yySindex[yyState]) != 0 && ((yyN += yyToken) >= 0) && (yyN < yyTable.Length) && (yyCheck[yyN] == yyToken)) { if (debug != null) debug.shift(yyState, yyTable[yyN], yyErrorFlag-1); yyState = yyTable[yyN]; // shift to yyN yyVal = yyLex.value(); yyToken = -1; if (yyErrorFlag > 0) -- yyErrorFlag; goto continue_yyLoop; } if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0 && yyN < yyTable.Length && yyCheck[yyN] == yyToken) yyN = yyTable[yyN]; // reduce (yyN) else switch (yyErrorFlag) { case 0: yyExpectingState = yyState; // yyerror(String.Format ("syntax error, got token `{0}'", yyname (yyToken)), yyExpecting(yyState)); if (debug != null) debug.error("syntax error"); if (yyToken == 0 /*eof*/ || yyToken == eof_token) throw new yyParser.yyUnexpectedEof (); goto case 1; case 1: case 2: yyErrorFlag = 3; do { if ((yyN = yySindex[yyStates[yyTop]]) != 0 && (yyN += Token.yyErrorCode) >= 0 && yyN < yyTable.Length && yyCheck[yyN] == Token.yyErrorCode) { if (debug != null) debug.shift(yyStates[yyTop], yyTable[yyN], 3); yyState = yyTable[yyN]; yyVal = yyLex.value(); goto continue_yyLoop; } if (debug != null) debug.pop(yyStates[yyTop]); } while (-- yyTop >= 0); if (debug != null) debug.reject(); throw new yyParser.yyException("irrecoverable syntax error"); case 3: if (yyToken == 0) { if (debug != null) debug.reject(); throw new yyParser.yyException("irrecoverable syntax error at end-of-file"); } if (debug != null) debug.discard(yyState, yyToken, yyname(yyToken), yyLex.value()); yyToken = -1; goto continue_yyDiscarded; // leave stack alone } } int yyV = yyTop + 1-yyLen[yyN]; if (debug != null) debug.reduce(yyState, yyStates[yyV-1], yyN, YYRules.getRule (yyN), yyLen[yyN]); yyVal = yyV > yyTop ? null : yyVals[yyV]; // yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]); switch (yyN) { case 1: #line 177 "src/mml_parser.jay" { yyVal = new List<MmlOperationUse> (); } break; case 4: case_4(); break; case 5: case_5(); break; case 6: #line 199 "src/mml_parser.jay" { current_location = ((MmlToken) yyVals[0+yyTop]).Location; } break; case 7: case_7(); break; case 9: #line 216 "src/mml_parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 10: #line 222 "src/mml_parser.jay" { yyVal = new List<MmlValueExpr> (); } break; case 12: case_12(); break; case 13: case_13(); break; case 14: #line 244 "src/mml_parser.jay" { yyVal = skipped_argument; } break; case 19: #line 258 "src/mml_parser.jay" { yyVal = new MmlConditionalExpr ((MmlValueExpr) yyVals[-4+yyTop], (MmlValueExpr) yyVals[-2+yyTop], (MmlValueExpr) yyVals[0+yyTop]); } break; case 21: #line 265 "src/mml_parser.jay" { yyVal = new MmlComparisonExpr ((MmlValueExpr) yyVals[-2+yyTop], (MmlValueExpr) yyVals[0+yyTop], (ComparisonType) yyVals[-1+yyTop]); } break; case 22: #line 271 "src/mml_parser.jay" { yyVal = ComparisonType.Lesser; } break; case 23: #line 275 "src/mml_parser.jay" { yyVal = ComparisonType.LesserEqual; } break; case 24: #line 279 "src/mml_parser.jay" { yyVal = ComparisonType.Greater; } break; case 25: #line 283 "src/mml_parser.jay" { yyVal = ComparisonType.GreaterEqual; } break; case 27: #line 290 "src/mml_parser.jay" { yyVal = new MmlAddExpr ((MmlValueExpr) yyVals[-2+yyTop], (MmlValueExpr) yyVals[0+yyTop]); } break; case 28: #line 294 "src/mml_parser.jay" { yyVal = new MmlAddExpr ((MmlValueExpr) yyVals[-2+yyTop], (MmlValueExpr) yyVals[0+yyTop]); } break; case 29: #line 298 "src/mml_parser.jay" { yyVal = new MmlSubtractExpr ((MmlValueExpr) yyVals[-2+yyTop], (MmlValueExpr) yyVals[0+yyTop]); } break; case 31: #line 305 "src/mml_parser.jay" { yyVal = new MmlMultiplyExpr ((MmlValueExpr) yyVals[-2+yyTop], (MmlValueExpr) yyVals[0+yyTop]); } break; case 32: #line 309 "src/mml_parser.jay" { yyVal = new MmlDivideExpr ((MmlValueExpr) yyVals[-2+yyTop], (MmlValueExpr) yyVals[0+yyTop]); } break; case 33: #line 313 "src/mml_parser.jay" { yyVal = new MmlModuloExpr ((MmlValueExpr) yyVals[-2+yyTop], (MmlValueExpr) yyVals[0+yyTop]); } break; case 36: #line 321 "src/mml_parser.jay" { yyVal = new MmlParenthesizedExpr ((MmlValueExpr) yyVals[-1+yyTop]); } break; case 40: #line 330 "src/mml_parser.jay" { yyVal = new MmlMultiplyExpr (new MmlConstantExpr (MmlDataType.Number, -1), (MmlValueExpr) yyVals[0+yyTop]); } break; case 41: #line 334 "src/mml_parser.jay" { yyVal = new MmlAddExpr (new MmlVariableReferenceExpr ("__length"), (MmlValueExpr) yyVals[0+yyTop]); } break; case 42: case_42(); break; case 43: case_43(); break; case 44: case_44(); break; case 45: case_45(); break; case 46: case_46(); break; case 47: case_47(); break; case 48: case_48(); break; case 49: #line 387 "src/mml_parser.jay" { yyVal = 1; } break; case 50: #line 391 "src/mml_parser.jay" { yyVal = ((int) yyVals[-1+yyTop]) + 1; } break; #line default } yyTop -= yyLen[yyN]; yyState = yyStates[yyTop]; int yyM = yyLhs[yyN]; if (yyState == 0 && yyM == 0) { if (debug != null) debug.shift(0, yyFinal); yyState = yyFinal; if (yyToken < 0) { yyToken = yyLex.advance() ? yyLex.token() : 0; if (debug != null) debug.lex(yyState, yyToken,yyname(yyToken), yyLex.value()); } if (yyToken == 0) { if (debug != null) debug.accept(yyVal); return yyVal; } goto continue_yyLoop; } if (((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0) && (yyN < yyTable.Length) && (yyCheck[yyN] == yyState)) yyState = yyTable[yyN]; else yyState = yyDgoto[yyM]; if (debug != null) debug.shift(yyStates[yyTop], yyState); goto continue_yyLoop; continue_yyDiscarded: ; // implements the named-loop continue: 'continue yyDiscarded' } continue_yyLoop: ; // implements the named-loop continue: 'continue yyLoop' } }