Exemple #1
0
 public void SyntaxError(IRecognizer recognizer, T offendingSymbol, int line, int charPositionInLine, string msg,
                         RecognitionException e)
 {
     if (recognizer is MalinaParser)
     {
         if (offendingSymbol != null)
         {
             var tokenName =
                 ((MalinaParser)recognizer).Vocabulary.GetDisplayName((offendingSymbol as CommonToken).Type);
             _context.AddError(CompilerErrorFactory.ParserError(e,
                                                                $"Unexpected token {tokenName}<'{(offendingSymbol as CommonToken).Text}'>",
                                                                _fileName, (offendingSymbol as CommonToken).Line,
                                                                (offendingSymbol as CommonToken).Column + 1));
         }
         else
         {
             _context.AddError(CompilerErrorFactory.ParserError(e, msg, _fileName, line,
                                                                charPositionInLine + 1));
         }
     }
     else if (recognizer is MalinaLexer)
     {
         _context.AddError(CompilerErrorFactory.LexerError(e, msg, _fileName, line, charPositionInLine));
     }
     else
     {
         _context.AddError(CompilerErrorFactory.FatalError(e, msg));
     }
 }
Exemple #2
0
 internal void ProcessParameter(Parameter node)
 {
     if (_currentModuleMember is Document)
     {
         _context.AddError(CompilerErrorFactory.ParametersCantBeDeclaredInDocuments(node, _currentModule.FileName));
     }
     else
     {
         ((AliasDefinition)_currentModuleMember).Parameters.Add(node);
         if (node.Name == "_")
         {
             if (!node.IsValueNode)
             {
                 ((AliasDefinition)_currentModuleMember).HasDefaultBlockParameter = true;
             }
             else
             {
                 ((AliasDefinition)_currentModuleMember).HasDefaultValueParameter = true;
             }
         }
     }
 }