ExpressionType TranslateExpression(BreakExpression e) { if (!Env.LoopEnvironment.InLoop()) { Error.Report(e.Pos, "No loop to break"); return(new ExpressionType(null, Types.Type._void)); } return(new ExpressionType(Translate.TranslateBreakExp(Env.LoopEnvironment.Done()), Types.Type._void)); }
public static BreakExpression Create( AphidExpressionContext context_aphidExpressionContext, int value_i, int value_i1 ) { BreakExpression breakExpression = new BreakExpression(context_aphidExpressionContext); ((AphidExpression)breakExpression).Index = value_i; ((AphidExpression)breakExpression).Length = value_i1; return(breakExpression); // TODO: Edit factory method of BreakExpression // This method should be able to configure the object in all possible ways. // Add as many parameters as needed, // and assign their values to each field by using the API. }
public static void RegisterAll() { BreakExpression.Register(); ContinueExpression.Register(); ReturnFunctionExpression.Register(); AbsFunction.Register(); ExecuteFile.Register(); PowFunction.Register(); ProductFunction.Register(); HelpFunction.Register(); SqrtFunction.Register(); SumDeepFunction.Register(); SumFunction.Register(); LengthFunction.Register(); ConsoleObject.Register(); TrigonometryObject.Register(); ThisConstant.Register(); BooleanValue.Register(); ComplexValue.Register(); DecimalValue.Register(); NullValue.Register(); }
public Expression ParseFactor() { Expression exp; switch (_currentToken.TokenType) { case AphidTokenType.LeftBrace: exp = ParseObjectExpression(); break; case AphidTokenType.LeftBracket: exp = ParseArrayExpression(); break; case AphidTokenType.LeftParenthesis: NextToken(); exp = ParseExpression(); Match(AphidTokenType.RightParenthesis); break; case AphidTokenType.String: exp = ParseStringExpression(); break; case AphidTokenType.Number: exp = ParseNumberExpression(); break; case AphidTokenType.MinusOperator: NextToken(); var numExp = ParseNumberExpression(); numExp.Value *= -1; exp = numExp; break; case AphidTokenType.Identifier: exp = ParseIdentifierExpression(); if (_currentToken.TokenType == AphidTokenType.definedKeyword) { NextToken(); exp = new UnaryOperatorExpression(AphidTokenType.definedKeyword, exp) { IsPostfix = true }; } break; case AphidTokenType.functionOperator: exp = ParseFunctionExpression(); break; //case AphidTokenType.forKeyword: // exp = ParseForExpression(); // break; case AphidTokenType.retKeyword: case AphidTokenType.deleteKeyword: exp = ParseUnaryExpression(); break; case AphidTokenType.trueKeyword: exp = new BooleanExpression(true); NextToken(); break; case AphidTokenType.falseKeyword: exp = new BooleanExpression(false); NextToken(); break; case AphidTokenType.thisKeyword: exp = new ThisExpression(); NextToken(); break; //case AphidTokenType.extendKeyword: // exp = ParseExtendExpression(); // break; //case AphidTokenType.ifKeyword: // exp = ParseIfExpression(); // break; case AphidTokenType.LoadScriptOperator: exp = ParseLoadScriptExpression(); break; case AphidTokenType.LoadLibraryOperator: exp = ParseLoadLibraryExpression(); break; case AphidTokenType.nullKeyword: exp = new NullExpression(); NextToken(); break; case AphidTokenType.breakKeyword: exp = new BreakExpression(); NextToken(); break; case AphidTokenType.HexNumber: exp = new NumberExpression((decimal)Convert.ToInt64(_currentToken.Lexeme.Substring(2), 16)); NextToken(); break; case AphidTokenType.PatternMatchingOperator: var matchExp = new PatternMatchingExpression(); NextToken(); Match(AphidTokenType.LeftParenthesis); matchExp.TestExpression = ParseExpression(); Match(AphidTokenType.RightParenthesis); while (true) { var tests = new List <Expression>(); while (true) { tests.Add(ParseExpression()); if (_currentToken.TokenType == AphidTokenType.Comma) { NextToken(); } else { break; } } if (_currentToken.TokenType == AphidTokenType.ColonOperator) { NextToken(); var b = ParseExpression(); foreach (var t in tests) { matchExp.Patterns.Add(new Tuple <Expression, Expression>(t, b)); } } else { matchExp.Patterns.Add(new Tuple <Expression, Expression>(null, tests[0])); } if (_currentToken.TokenType == AphidTokenType.Comma) { NextToken(); } else { break; } } exp = matchExp; break; default: throw new AphidParserException(_currentToken); } return(exp); }
public virtual T Visit(BreakExpression expression) { return(default(T)); }
public Expression ParseFactor() { Expression exp; switch (_currentToken.TokenType) { case AphidTokenType.LeftBrace: exp = ParseObjectExpression(); break; case AphidTokenType.LeftBracket: exp = ParseArrayExpression(); break; case AphidTokenType.LeftParenthesis: NextToken(); exp = ParseExpression(); Match(AphidTokenType.RightParenthesis); break; case AphidTokenType.String: exp = ParseStringExpression(); break; case AphidTokenType.Number: exp = ParseNumberExpression(); break; case AphidTokenType.Identifier: exp = ParseIdentifierExpression(); break; case AphidTokenType.functionOperator: exp = ParseFunctionExpression(); break; case AphidTokenType.forKeyword: exp = ParseForExpression(); break; case AphidTokenType.retKeyword: exp = ParseReturnExpression(); break; case AphidTokenType.trueKeyword: exp = new BooleanExpression(true); NextToken(); break; case AphidTokenType.falseKeyword: exp = new BooleanExpression(false); NextToken(); break; case AphidTokenType.thisKeyword: exp = new ThisExpression(); NextToken(); break; case AphidTokenType.ifKeyword: exp = ParseIfExpression(); break; case AphidTokenType.LoadScriptOperator: exp = ParseLoadScriptExpression(); break; case AphidTokenType.LoadLibraryOperator: exp = ParseLoadLibraryExpression(); break; case AphidTokenType.nullKeyword: exp = new NullExpression(); NextToken(); break; case AphidTokenType.breakKeyword: exp = new BreakExpression(); NextToken(); break; case AphidTokenType.HexNumber: exp = new NumberExpression((decimal)Convert.ToInt64(_currentToken.Lexeme.Substring(2), 16)); NextToken(); break; default: throw new AphidParserException(_currentToken); } switch (_currentToken.TokenType) { case AphidTokenType.LeftBracket: if (exp is ArrayExpression) { break; } NextToken(); var key = ParseExpression(); Match(AphidTokenType.RightBracket); exp = new ArrayAccessExpression(exp, key); break; } return(exp); }
private static CodeStatementCollection GenerateImperativeStatement(BreakExpression node) => new CodeStatementCollection(new[] { new CodeSnippetStatement("break;") });
void PrintExpression(BreakExpression e, int d) { Say("BreakExpression()"); }
void PrintExpression(BreakExpression e, int d) { Say("BreakExpression()"); }
public virtual Expression Visit(BreakExpression expression) { return(expression); }
public virtual bool VisitBreakExpression(BreakExpression breakExpression) { VisitExpression(breakExpression); return(true); }
[DebuggerStepThrough] protected virtual void EmitBreakExpression(BreakExpression expression, bool isStatement = false) { throw new NotImplementedException(); }
public static Result Run(BreakExpression block, Scope scope) { throw new BreakException(Interpreters.Execute(block.CountOfLoops, scope).ResultValue.GetLongValue().Clamp(1, 1000)); }
public int Visit(BreakExpression expression) { _writer.Write("break"); return(0); }
protected override void EmitBreakExpression(BreakExpression expression, bool isStatement = false) => Append("break");