コード例 #1
0
 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()));
 }
コード例 #2
0
 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));
 }
コード例 #3
0
ファイル: AntlrConverter.cs プロジェクト: smartfish/PT.PM
        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);
        }
コード例 #4
0
        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
            });
        }
コード例 #5
0
ファイル: AntlrConverter.cs プロジェクト: smartfish/PT.PM
 protected AssignmentExpression CreateAssignExpr(Expression left, Expression right, ParserRuleContext context, ParserRuleContext assignOperator)
 {
     return(UstUtils.CreateAssignExpr(left, right, context.GetTextSpan(), assignOperator?.GetText(), assignOperator?.GetTextSpan() ?? TextSpan.Zero));
 }