protected ParseErrorAbstract(
     Antlr4.Runtime.Parser parser,
     DFA dFA,
     int startIndex,
     int stopIndex)
 {
     Parser     = parser;
     DFA        = dFA;
     StartIndex = startIndex;
     StopIndex  = stopIndex;
 }
 public AttemptingFullContextParseError(
     Antlr4.Runtime.Parser parser,
     DFA dFA,
     int startIndex,
     int stopIndex,
     BitSet conflictingAlts,
     SimulatorState confictState)
     : base(parser, dFA, startIndex, stopIndex)
 {
     ConflictingAlts = conflictingAlts;
     ConfictState    = confictState;
 }
Exemplo n.º 3
0
 public ContextSensivityParseError(
     Antlr4.Runtime.Parser parser,
     DFA dFA,
     int startIndex,
     int stopIndex,
     int prediction,
     SimulatorState acceptState)
     : base(parser, dFA, startIndex, stopIndex)
 {
     Prediction  = prediction;
     AcceptState = acceptState;
 }
 public AmbiguityParseError(
     Antlr4.Runtime.Parser parser,
     DFA dFA,
     int startIndex,
     int stopIndex,
     bool exact,
     BitSet ambigAlts,
     ATNConfigSet configs)
     : base(parser, dFA, startIndex, stopIndex)
 {
     Exact     = exact;
     AmbigAlts = ambigAlts;
     Configs   = configs;
 }
Exemplo n.º 5
0
        internal void UpdateMatchings()
        {
            sourceCodeLogger.Clear();

            var sourceCodeRep = new MemoryCodeRepository(sourceCodeTextBox.Text);
            IPatternsRepository patternRepository;

            if (!string.IsNullOrEmpty(ServiceLocator.PatternViewModel.Value))
            {
                patternRepository = new DslPatternRepository(ServiceLocator.PatternViewModel.Value, ServiceLocator.PatternViewModel.Languages);
            }
            else
            {
                patternRepository = new MemoryPatternsRepository();
            }
            var workflow = new Workflow(sourceCodeRep, SelectedLanguage, patternRepository, stage: Stage);

            workflow.IsIncludeIntermediateResult = true;
            workflow.Logger = sourceCodeLogger;
            WorkflowResult workflowResult = workflow.Process();

            MatchingResultDto[] matchingResults = workflowResult.MatchingResults
                                                  .ToDto(workflow.SourceCodeRepository)
                                                  .ToArray();

            if (IsDeveloperMode)
            {
                AntlrParseTree antlrParseTree = workflowResult.ParseTrees.FirstOrDefault() as AntlrParseTree;
                if (antlrParseTree != null && antlrParseTree.SyntaxTree != null)
                {
                    Antlr4.Runtime.Parser antlrParser = (workflow.ParserConverterSets[antlrParseTree.SourceLanguage].Parser as AntlrParser).Parser;
                    string tokensString = AntlrHelper.GetTokensString(antlrParseTree.Tokens, antlrParser.Vocabulary, onlyDefaultChannel: true);
                    string treeString   = antlrParseTree.SyntaxTree.ToStringTreeIndented(antlrParser);

                    Tokens    = tokensString;
                    ParseTree = treeString;
                    File.WriteAllText(Path.Combine(ServiceLocator.TempDirectory, "Tokens.txt"), Tokens);
                    File.WriteAllText(Path.Combine(ServiceLocator.TempDirectory, "Tree.txt"), ParseTree);
                }
                if (Stage >= Stage.Convert && workflowResult.Usts.FirstOrDefault() != null)
                {
                    UstJson = jsonSerializer.Serialize(workflowResult.Usts.FirstOrDefault().Root);
                    File.WriteAllText(Path.Combine(ServiceLocator.TempDirectory, "UST.json"), UstJson);
                }
            }

            MatchingResultText = "MATCHINGS";
            if (matchingResults.Count() > 0)
            {
                MatchingResultText += " (" + matchingResults.Count() + ")";
            }

            if (sourceCodeLogger.ErrorCount == 0)
            {
                SourceCodeErrorsIsVisible = false;
                SourceCodeErrorsText      = "ERRORS";
            }
            else
            {
                SourceCodeErrorsIsVisible = true;
                SourceCodeErrorsText      = $"ERRORS ({sourceCodeLogger.ErrorCount})";
            }

            Dispatcher.UIThread.InvokeAsync(() =>
            {
                MatchingResults.Clear();
                foreach (var matchingResult in matchingResults)
                {
                    MatchingResults.Add(new MathingResultDtoWrapper(matchingResult));
                }
                this.RaisePropertyChanged(nameof(Tokens));
                this.RaisePropertyChanged(nameof(ParseTree));
                this.RaisePropertyChanged(nameof(UstJson));
                this.RaisePropertyChanged(nameof(MatchingResultText));
                this.RaisePropertyChanged(nameof(SourceCodeErrorsIsVisible));
                this.RaisePropertyChanged(nameof(SourceCodeErrorsText));
            });
        }