private InvocationExpression CreateSpecialInvocation(ITerminalNode name, ParserRuleContext context, List <Expression> expressions) { return(new InvocationExpression( new IdToken(name.Symbol.Text.ToLowerInvariant(), name.GetTextSpan()), new ArgsUst(expressions), context.GetTextSpan())); }
private InvocationExpression CreateSpecialInvocation(ITerminalNode name, ParserRuleContext context, Expression expression) { return(new InvocationExpression( new IdToken(name.Symbol.Text.ToLowerInvariant(), name.GetTextSpan(), FileNode), new ArgsNode(expression), context.GetTextSpan(), FileNode)); }
private Expression CreateBinaryOperatorExpression(ParserRuleContext left, string operatorText, TextSpan operatorTextSpan, ParserRuleContext right) { BinaryOperator binaryOperator = BinaryOperatorLiteral.TextBinaryOperator[operatorText]; var expression0 = (Expression)Visit(left); var expression1 = (Expression)Visit(right); var result = new BinaryOperatorExpression( expression0, new BinaryOperatorLiteral(binaryOperator, operatorTextSpan), expression1, left.GetTextSpan().Union(right.GetTextSpan())); return(result); }
public static void LogConversionError(Exception ex, ParserRuleContext context, string currentFileName, string currentFileData, ILogger logger) { StackTrace stackTrace = new StackTrace(ex, true); int frameNumber = 0; string fileName = null; string methodName = null; int line = 0; int column = 0; do { StackFrame frame = stackTrace.GetFrame(frameNumber); fileName = frame.GetFileName(); methodName = frame.GetMethod().Name; line = frame.GetFileLineNumber(); column = frame.GetFileColumnNumber(); frameNumber++; }while (frameNumber < stackTrace.FrameCount && (fileName == null || methodName == "Visit")); var textSpan = context.GetTextSpan(); string exceptionText; int sourceCodeLine, sourceCodeColumn; TextHelper.LinearToLineColumn(textSpan.Start, currentFileData, out sourceCodeLine, out sourceCodeColumn); if (fileName != null) { exceptionText = $"{ex.Message} at method \"{methodName}\" {line}:{column} at position {sourceCodeLine}:{sourceCodeColumn} in source file"; } else { exceptionText = $"{ex.Message} at position {sourceCodeLine}:{sourceCodeColumn} in source file"; } logger.LogError(new ConversionException(currentFileName, message: exceptionText) { TextSpan = textSpan }); }
protected AssignmentExpression CreateAssignExpr(Expression left, Expression right, ParserRuleContext context, ParserRuleContext assignOperator) { return(UstUtils.CreateAssignExpr(left, right, context.GetTextSpan(), assignOperator?.GetText(), assignOperator?.GetTextSpan() ?? TextSpan.Zero)); }