コード例 #1
0
      public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
      {
         Console.Error.WriteLine("line " + line + ":" + charPositionInLine + " " + msg);
         underlineError(recognizer, (IToken)offendingSymbol,
      line, charPositionInLine);

      }
コード例 #2
0
 public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     NotificationManager.AddNotification(
         new ParseError (
             string.Format("line {0} : {1} at {2} : {3}", line, charPositionInLine, offendingSymbol, msg)
             ));
 }
コード例 #3
0
 public RecognitionException(Lexer lexer, ICharStream input)
 {
     // TODO: make a dummy recognizer for the interpreter to use?
     // Next two (ctx,input) should be what is in recognizer, but
     // won't work when interpreting
     this.recognizer = lexer;
     this.input = input;
 }
コード例 #4
0
        public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e) {

            base.SyntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);

            var error = SyntaxErrorFactory.CreateDiagnostic(offendingSymbol, line, charPositionInLine, msg, _filePath);

            _diagnostics.Add(error);
        }
コード例 #5
0
 public NoViableAltException(IRecognizer recognizer, ITokenStream input, IToken startToken, IToken offendingToken, ATNConfigSet deadEndConfigs, ParserRuleContext ctx)
     : base(recognizer, input, ctx)
 {
     // LL(1) error
     this.deadEndConfigs = deadEndConfigs;
     this.startToken = startToken;
     this.OffendingToken = offendingToken;
 }
コード例 #6
0
ファイル: ErrorListener.cs プロジェクト: IraPro/MyProject
 public override void SyntaxError(IRecognizer recognizer,
     IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     MainForm f = (MainForm)Application.OpenForms[0];
     TextBox tx = f.resultBox;
     tx.Text += Environment.NewLine + Environment.NewLine + "> line " + line.ToString() + ":" + charPositionInLine.ToString() + " at " + offendingSymbol.ToString() + ": " + msg;
        
 }
コード例 #7
0
 public ORegexSyntaxException(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine,
     string msg,
     RecognitionException e) : base(msg, e)
 {
     Recognizer = recognizer;
     OffendingSymbol = offendingSymbol;
     Line = line;
     CharPositionInLine = charPositionInLine;
 }
コード例 #8
0
 public RecognitionException(IRecognizer recognizer, IIntStream input, ParserRuleContext ctx)
 {
     this.recognizer = recognizer;
     this.input = input;
     this.ctx = ctx;
     if (recognizer != null)
     {
         this.offendingState = recognizer.State;
     }
 }
コード例 #9
0
        public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg,
            RecognitionException e)
        {
            base.SyntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
            
            InvokeErrorEvent(new LiquidError
            {
                TokenSource = offendingSymbol.TokenSource.SourceName,
                //Context = offendingSymbol..SourceName,
                Message = msg, 
                Line = line, 
                CharPositionInLine = charPositionInLine,
                OffendingSymbol = offendingSymbol.Text
            });

        }
コード例 #10
0
 protected void underlineError(IRecognizer recognizer, IToken offendingToken, int line, int charPositionInLine)
 {
    CommonTokenStream tokens = (CommonTokenStream)recognizer.InputStream;
    String input = tokens.TokenSource.InputStream.ToString();
    String[] lines = input.Split('\n');
    String errorLine = lines[line - 1];
    Console.Error.WriteLine(errorLine);
    for (int i = 0; i < charPositionInLine; i++)
       Console.Error.Write(" ");
    int start = offendingToken.StartIndex;
    int stop = offendingToken.StopIndex;
    if (start >= 0 && stop >= 0)
    {
       for (int i = start; i <= stop; i++) Console.Error.Write("^");
    }
    Console.Error.WriteLine();
 }
コード例 #11
0
        /// <summary>
        /// Setup a controller with the recognizer and a data container instance.
        /// 
        /// Creates the pipelines for physical and interpreted gestures.
        /// </summary>
        /// <param name="recognizer">the recognizer</param>
        public TrameGestureController(IRecognizer recognizer)
        {
            // tasks
            var smoothingTask = new SmoothingTask();
            var recognitionTask = new RecognitionTask(recognizer);
            var physicsCalculationTask = new PhysicCalculationTask();
            // buffers
            _skeletonBuffer = new BlockingCollection<ISkeleton>();
            _skeletonBuffer2 = new BlockingCollection<ISkeleton>();
            var secondBuffer = new BlockingCollection<ISkeleton>(1000);

            var f = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.None);
            // interpreted
            var smoothing = f.StartNew(() => smoothingTask.Do(_skeletonBuffer, secondBuffer));
            var recognition = f.StartNew(() => recognitionTask.Do(secondBuffer, FireNewMotions));
            // physics
            var physics = f.StartNew(() => physicsCalculationTask.Do(_skeletonBuffer2, FireNewCommand));
            _thread = new Thread(() => { System.Threading.Tasks.Task.WaitAll(smoothing, physics, recognition); });
            _thread.Start();
        }
コード例 #12
0
        /// <summary>
        /// Register a ParserDiagnostic for each syntax error encountered by the parser
        /// </summary>
        public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
        {
            // Build a string representing the current grammar rules being recognized
            StringBuilder ruleStack = new StringBuilder();
            IList<String> stack = ((Antlr4.Runtime.Parser)recognizer).GetRuleInvocationStack();
            bool isFirst = true;
            foreach (string ruleInvocation in stack.Reverse())
            {
                if(isFirst) { isFirst = false;  }
                else
                {
                    ruleStack.Append('>');
                }
                ruleStack.Append(ruleInvocation);
            }

            // Register a new diagnostic
            ParserDiagnostic diagnostic = new ParserDiagnostic(msg, offendingSymbol, ruleStack.ToString());
            Diagnostics.Add(diagnostic);
        }
コード例 #13
0
        public override void SyntaxError(IRecognizer recognizer,
                IToken offendingSymbol,
                int line, int charPositionInLine,
                string msg,
                RecognitionException e)
        {
            List<String> stack = new List<string>(((Parser)recognizer).GetRuleInvocationStack());

            stack.Reverse();

            if (!foundErrors) {
                myErrorTB.Text = "Parsing Errors:" + Environment.NewLine;
                foundErrors = true;
            }
            string theError = "";

            theError += "rule stack: " + stack.ToString() + Environment.NewLine;
            theError += "line: " + line + ":" + charPositionInLine + " at " + offendingSymbol + ": " + msg + Environment.NewLine;
            if (theError.Length > 0)
                myErrorTB.Text += Environment.NewLine + theError;
        }
コード例 #14
0
		/// <summary>
		/// Performs the actual parsing and tokenizing of the query string making appropriate
		/// callbacks to the given recognizer upon recognition of the various tokens.
		/// </summary>
		/// <remarks>
		/// Note that currently, this only knows how to deal with a single output
		/// parameter (for callable statements).  If we later add support for
		/// multiple output params, this, obviously, needs to change.
		/// </remarks>
		/// <param name="sqlString">The string to be parsed/tokenized.</param>
		/// <param name="recognizer">The thing which handles recognition events.</param>
		/// <exception cref="QueryException" />
		public static void Parse(string sqlString, IRecognizer recognizer)
		{
			bool hasMainOutputParameter = sqlString.IndexOf("call") > 0 &&
			                              sqlString.IndexOf("?") < sqlString.IndexOf("call") &&
			                              sqlString.IndexOf("=") < sqlString.IndexOf("call");
			bool foundMainOutputParam = false;

			int stringLength = sqlString.Length;
			bool inQuote = false;
			for (int indx = 0; indx < stringLength; indx++)
			{
				char c = sqlString[indx];
				if (inQuote)
				{
					if ('\'' == c)
					{
						inQuote = false;
					}
					recognizer.Other(c);
				}
				else if ('\'' == c)
				{
					inQuote = true;
					recognizer.Other(c);
				}
				else
				{
					if (c == ':')
					{
						// named parameter
						int right = StringHelper.FirstIndexOfChar(sqlString, ParserHelper.HqlSeparators, indx + 1);
						int chopLocation = right < 0 ? sqlString.Length : right;
						string param = sqlString.Substring(indx + 1, chopLocation - (indx + 1));
						recognizer.NamedParameter(param, indx);
						indx = chopLocation - 1;
					}
					else if (c == '?')
					{
						// could be either an ordinal or ejb3-positional parameter
						if (indx < stringLength - 1 && char.IsDigit(sqlString[indx + 1]))
						{
							// a peek ahead showed this as an ejb3-positional parameter
							int right = StringHelper.FirstIndexOfChar(sqlString, ParserHelper.HqlSeparators, indx + 1);
							int chopLocation = right < 0 ? sqlString.Length : right;
							string param = sqlString.Substring(indx + 1, chopLocation - (indx + 1));
							// make sure this "name" is an integral
							try
							{
								int.Parse(param);
							}
							catch (FormatException e)
							{
								throw new QueryException("ejb3-style positional param was not an integral ordinal", e);
							}
							recognizer.Ejb3PositionalParameter(param, indx);
							indx = chopLocation - 1;
						}
						else
						{
							if (hasMainOutputParameter && !foundMainOutputParam)
							{
								foundMainOutputParam = true;
								recognizer.OutParameter(indx);
							}
							else
							{
								recognizer.OrdinalParameter(indx);
							}
						}
					}
					else
					{
						recognizer.Other(c);
					}
				}
			}
		}
コード例 #15
0
 public override void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     _errorHandler.AddError(line, msg);
 }
コード例 #16
0
 public void SyntaxError(TextWriter output, IRecognizer recognizer, TSymbol offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     throw new Exception($"line {line}:{charPositionInLine} {msg}");
 }
コード例 #17
0
ファイル: ErrorListener.cs プロジェクト: nlcamp/iotedge
 /// <summary>
 /// Syntax error for parser
 /// </summary>
 /// <param name="recognizer"></param>
 /// <param name="offendingSymbol"></param>
 /// <param name="line"></param>
 /// <param name="charPositionInLine"></param>
 /// <param name="msg"></param>
 /// <param name="e"></param>
 public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     this.Error(offendingSymbol, "Syntax error.");
 }
コード例 #18
0
 public DFASerializer(DFA dfa, IRecognizer parser)
     : this(dfa, parser != null ? parser.Vocabulary : Vocabulary.EmptyVocabulary, parser != null ? parser.RuleNames : null, parser != null ? parser.Atn : null)
 {
 }
コード例 #19
0
 public GetNextController(IRecognizer recognizer)
 {
     nm = recognizer.NeuralImage;
 }
コード例 #20
0
 public override void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     ExceptionList.Add(msg);
     base.SyntaxError(output, recognizer, offendingSymbol, line, charPositionInLine, msg, e);
 }
コード例 #21
0
 /// <summary>
 /// 
 /// </summary>
 public RecognitionTask(IRecognizer recognizer)
 {
     Recognizer = recognizer;
     recognizer.Initialize(TemplateFactory.CreateTemplates());
 }
コード例 #22
0
 private void CreateMainViewer(IRecognizer <string> recognizer)
 {
     var viewer = new MainViewer <string>(this, recognizer);
 }
コード例 #23
0
        // if you are generating the parser with the Java tool change the signature to the following
        // public override void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
        public override void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
        {
            Writer.WriteLine(msg);

            Symbol = offendingSymbol.Text;
        }
コード例 #24
0
 public virtual void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
 }
コード例 #25
0
 public virtual string ToString(IRecognizer recog, bool showAlt)
 {
     return(ToString(recog, showAlt, true));
 }
コード例 #26
0
ファイル: AntlrErrors.cs プロジェクト: zihotki/Excess
 public void SyntaxError(IRecognizer recognizer, TToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     _scope.AddError("grammar syntax error", msg, _offset + offendingSymbol.StartIndex, offendingSymbol.StopIndex - offendingSymbol.StartIndex);
 }
コード例 #27
0
 public override string[] ToStrings(IRecognizer recognizer, PredictionContext stop, int currentState)
 {
     return new string[] { "[]" };
 }
コード例 #28
0
 public void SyntaxError(TextWriter output, IRecognizer recognizer, int offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     ExceptionList.Add(msg);
 }
コード例 #29
0
		/// <summary>
		/// Performs the actual parsing and tokenizing of the query string making appropriate
		/// callbacks to the given recognizer upon recognition of the various tokens.
		/// </summary>
		/// <remarks>
		/// Note that currently, this only knows how to deal with a single output
		/// parameter (for callable statements).  If we later add support for
		/// multiple output params, this, obviously, needs to change.
		/// </remarks>
		/// <param name="sqlString">The string to be parsed/tokenized.</param>
		/// <param name="recognizer">The thing which handles recognition events.</param>
		/// <exception cref="QueryException" />
		public static void Parse(string sqlString, IRecognizer recognizer)
		{
			// TODO: WTF? "CALL"... it may work for ORACLE but what about others RDBMS ? (by FM)
			bool hasMainOutputParameter = sqlString.IndexOf("call") > 0 &&
										  sqlString.IndexOf("?") > 0 &&
										  sqlString.IndexOf("=") > 0 &&
										  sqlString.IndexOf("?") < sqlString.IndexOf("call") &&
										  sqlString.IndexOf("=") < sqlString.IndexOf("call");
			bool foundMainOutputParam = false;

			int stringLength = sqlString.Length;
			bool inQuote = false;
			bool afterNewLine = false;
			for (int indx = 0; indx < stringLength; indx++)
			{
				// check comments
				if (indx + 1 < stringLength && sqlString.Substring(indx,2) == "/*")
				{
					var closeCommentIdx = sqlString.IndexOf("*/", indx+2);
					recognizer.Other(sqlString.Substring(indx, (closeCommentIdx- indx)+2));
					indx = closeCommentIdx + 1;
					continue;
				}
				if (afterNewLine && (indx + 1 < stringLength) && sqlString.Substring(indx, 2) == "--")
				{
					var closeCommentIdx = sqlString.IndexOf(Environment.NewLine, indx + 2);
					string comment;
					if (closeCommentIdx == -1)
					{
						closeCommentIdx = sqlString.Length;
						comment = sqlString.Substring(indx);
					}
					else
					{
						comment = sqlString.Substring(indx, closeCommentIdx - indx + Environment.NewLine.Length);
					}
					recognizer.Other(comment);
					indx = closeCommentIdx + NewLineLength - 1;
					continue;
				}
				if (indx + NewLineLength -1 < stringLength && sqlString.Substring(indx, NewLineLength) == Environment.NewLine)
				{
					afterNewLine = true;
					indx += NewLineLength - 1;
					recognizer.Other(Environment.NewLine);
					continue;
				}
				afterNewLine = false;

				char c = sqlString[indx];
				if (inQuote)
				{
					if ('\'' == c)
					{
						inQuote = false;
					}
					recognizer.Other(c);
				}
				else if ('\'' == c)
				{
					inQuote = true;
					recognizer.Other(c);
				}
				else
				{
					if (c == ':')
					{
						// named parameter
						int right = StringHelper.FirstIndexOfChar(sqlString, ParserHelper.HqlSeparators, indx + 1);
						int chopLocation = right < 0 ? sqlString.Length : right;
						string param = sqlString.Substring(indx + 1, chopLocation - (indx + 1));
						recognizer.NamedParameter(param, indx);
						indx = chopLocation - 1;
					}
					else if (c == '?')
					{
						// could be either an ordinal or ejb3-positional parameter
						if (indx < stringLength - 1 && char.IsDigit(sqlString[indx + 1]))
						{
							// a peek ahead showed this as an ejb3-positional parameter
							int right = StringHelper.FirstIndexOfChar(sqlString, ParserHelper.HqlSeparators, indx + 1);
							int chopLocation = right < 0 ? sqlString.Length : right;
							string param = sqlString.Substring(indx + 1, chopLocation - (indx + 1));
							// make sure this "name" is an integral
							try
							{
								int.Parse(param);
							}
							catch (FormatException e)
							{
								throw new QueryException("ejb3-style positional param was not an integral ordinal", e);
							}
							recognizer.JpaPositionalParameter(param, indx);
							indx = chopLocation - 1;
						}
						else
						{
							if (hasMainOutputParameter && !foundMainOutputParam)
							{
								foundMainOutputParam = true;
								recognizer.OutParameter(indx);
							}
							else
							{
								recognizer.OrdinalParameter(indx);
							}
						}
					}
					else
					{
						recognizer.Other(c);
					}
				}
			}
		}
コード例 #30
0
 public override void SyntaxError([NotNull] IRecognizer recognizer, [Nullable] IToken offendingSymbol, int line, int charPositionInLine, [NotNull] string msg, [Nullable] RecognitionException e)
 {
     Console.WriteLine("File {0}\r\n\tError : {1}\r\n\tLine: {2}", recognizer.InputStream.SourceName, msg, line);
     //base.SyntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
 }
コード例 #31
0
 public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg,
                                  RecognitionException e)
 {
     _errors.Add(new SyntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e));
 }
コード例 #32
0
 /// <summary>
 /// <inheritDoc/>
 /// <p>
 /// This implementation prints messages to
 /// <see cref="System.Console.Error"/>
 /// containing the
 /// values of
 /// <code>line</code>
 /// ,
 /// <code>charPositionInLine</code>
 /// , and
 /// <code>msg</code>
 /// using
 /// the following format.</p>
 /// <pre>
 /// line <em>line</em>:<em>charPositionInLine</em> <em>msg</em>
 /// </pre>
 /// </summary>
 public virtual void SyntaxError(IRecognizer recognizer, Symbol offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     System.Console.Error.WriteLine("line " + line + ":" + charPositionInLine + " " + msg);
 }
コード例 #33
0
        public VehicleSettingsDialog(
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <AutomotiveSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            IHttpContextAccessor httpContext)
            : base(nameof(VehicleSettingsDialog), services, responseManager, accessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            // Initialise supporting LUIS models for followup questions
            vehicleSettingNameSelectionLuisRecognizer  = services.LocaleConfigurations["en"].LuisServices["settings_name"];
            vehicleSettingValueSelectionLuisRecognizer = services.LocaleConfigurations["en"].LuisServices["settings_value"];

            // Initialise supporting LUIS models for followup questions
            vehicleSettingNameSelectionLuisRecognizer  = services.LocaleConfigurations["en"].LuisServices["settings_name"];
            vehicleSettingValueSelectionLuisRecognizer = services.LocaleConfigurations["en"].LuisServices["settings_value"];

            // Supporting setting files are stored as embeddded resources
            Assembly resourceAssembly = typeof(VehicleSettingsDialog).Assembly;

            var settingFile = resourceAssembly
                              .GetManifestResourceNames()
                              .Where(x => x.Contains(AvailableSettingsFileName))
                              .First();

            var alternativeSettingFileName = resourceAssembly
                                             .GetManifestResourceNames()
                                             .Where(x => x.Contains(AlternativeSettingsFileName))
                                             .First();

            if (string.IsNullOrEmpty(settingFile) || string.IsNullOrEmpty(alternativeSettingFileName))
            {
                throw new FileNotFoundException($"Unable to find Available Setting and/or Alternative Names files in \"{resourceAssembly.FullName}\" assembly.");
            }

            settingList   = new SettingList(resourceAssembly, settingFile, alternativeSettingFileName);
            settingFilter = new SettingFilter(settingList);

            // Setting Change waterfall
            var processVehicleSettingChangeWaterfall = new WaterfallStep[]
            {
                ProcessSetting,
                ProcessVehicleSettingsChange,
                ProcessChange,
                SendChange
            };

            AddDialog(new WaterfallDialog(Actions.ProcessVehicleSettingChange, processVehicleSettingChangeWaterfall)
            {
                TelemetryClient = telemetryClient
            });

            // Prompts
            AddDialog(new ChoicePrompt(Actions.SettingNameSelectionPrompt, SettingNameSelectionValidator, Culture.English)
            {
                Style = ListStyle.Inline, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });
            AddDialog(new ChoicePrompt(Actions.SettingValueSelectionPrompt, SettingValueSelectionValidator, Culture.English)
            {
                Style = ListStyle.Inline, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });

            AddDialog(new ConfirmPrompt(Actions.SettingConfirmationPrompt));

            // Set starting dialog for component
            InitialDialogId = Actions.ProcessVehicleSettingChange;

            // Used to resolve image paths (local or hosted)
            _httpContext = httpContext;
        }
コード例 #34
0
 public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     CompileStatus.AddError(new CompilerError(FileName, line, charPositionInLine, msg));
 }
コード例 #35
0
 /// <summary>
 /// Call into active IDialogDebugger and let it know that we are at given point in the Recognizer.
 /// </summary>
 /// <param name="context">dialogContext.</param>
 /// <param name="recognizer">recognizer.</param>
 /// <param name="more">label.</param>
 /// <param name="cancellationToken">cancellation token for async operations.</param>
 /// <returns>async task.</returns>
 public static async Task DebuggerStepAsync(this DialogContext context, IRecognizer recognizer, string more, CancellationToken cancellationToken)
 {
     await context.GetDebugger().StepAsync(context, recognizer, more, cancellationToken).ConfigureAwait(false);
 }
コード例 #36
0
ファイル: ETB.cs プロジェクト: jmclain/Nmp
		///////////////////////////////////////////////////////////////////////////////
		//
		//public Expression ParseExpression( IInput input )
		//{
		//	// ******
		//	CompoundExpression exList = new CompoundExpression();
		//
		//	// ******
		//	//
		//	// first token is the name of the macro
		//	//
		//	string	token = rootName;
		//	bool		haveFreshToken = true;
		//
		//	// ******
		//	while( true ) {
		//		bool isRootNode = 0 == exList.Count;
		//
		//		char ch = input.Peek();
		//
		//		if( SC.OPEN_PAREN == ch ) {
		//			//
		//			// '('
		//			//
		//			input.Skip( 1 );
		//			exList.Add( MethodCall(isRootNode, token, haveFreshToken, input) );
		//			haveFreshToken = false;
		//		}
		//		//else if( SC.OPEN_BRACKET == ch ) {
		//		//	//
		//		//	// '['
		//		//	//
		//		//	input.Skip( 1 );
		//		//	exList.Add( IndexMember(isRootNode, token, haveFreshToken, input) );
		//		//	haveFreshToken = false;                                               
		//		//}
		//		else {
		//			bool allDone = false;
		//
		//			if( haveFreshToken ) {
		//				allDone = HandleFreshToken( isRootNode, token, char.IsWhiteSpace(ch), exList, input );
		//				haveFreshToken = false;
		//			}
		//			
		//			if( SC.DOT == ch ) {
		//				//
		//				// '.'
		//				//
		//				input.Skip( 1 );
		//				token = GetToken( input );
		//			
		//				if( string.IsNullOrEmpty(token) ) {
		//					//
		//					// does not return
		//					//
		//					UnexpectedCharacter( input.Peek(), "expecting identifier (member name)" );
		//				}
		//			
		//				// ******
		//				haveFreshToken = true;
		//			}
		//
		//			else if( SC.OPEN_BRACKET == ch ) {
		//				//
		//				// '['
		//				//
		//				input.Skip( 1 );
		//				exList.Add( IndexMember(isRootNode, token, haveFreshToken, input) );
		//				haveFreshToken = false;                                               
		//			}
		//
		//			else if( SC.ATCHAR == ch && SC.OPEN_BRACKET == input.Peek(1) ) {
		//				input.Skip( 2 );
		//				ParseMacroOptions( input );
		//			}
		//			else {
		//				//
		//				// end of expression
		//				//
		//
		//				/*	
		//
		//					should put whatever we do here just before the end of the
		//					method - get it out of here for cleanthlyness sake
		//
		//
		//					if is altInvocationExpression and we did not detect it as a method in HandleFreshToken()
		//						
		//						we've hit ')' or some char we don't know what to do with
		//
		//					we could gather up "... )" and add to MacroOptions
		//
		//						or error
		//
		//						or just eat it
		//				*/
		//
		//		if( isAltInvocationExpression && ! allDone ) {
		//			NmpStringList strArgs = argScanner( input, RecognizedCharType.CloseParenChar );
		//		}
		//
		//
		//				break;
		//			}
		//		}
		//
		//		// ******
		//		//
		//		// since there is no member/token name for the result of an operation
		//		// we need to create one in case of cascading operations
		//		//
		//		if( !haveFreshToken ) {
		//			token = "result of " + token;
		//		}
		//	}
		//
		//	// ******
		//	return 1 == exList.Count ? exList[0] : exList;
		//}
		//

//		/////////////////////////////////////////////////////////////////////////////
//
//		public ETB( MIR mir, IScanner scanner, IRecognizer recognizer )
//		{
//			// ******
//			isAltInvocationExpression = mir.AltToken;
//
//			// ******
//			this.scanner = scanner;
//			this.recognizer = recognizer;
//
//			// ******
//			MacroInstructions = new NmpStringList();
//		}
//

		/////////////////////////////////////////////////////////////////////////////
		
		public ETB( string rootName, bool isAltInvocationExpression, IScanner scanner, IRecognizer recognizer )
		{
			// ******
			this.rootName = rootName;
			this.isAltInvocationExpression = isAltInvocationExpression;
		
			this.scanner = scanner;
			this.recognizer = recognizer;
		
			// ******
			//MacroInstructions = new NmpStringList();
		}
コード例 #37
0
 //IAntlrErrorListener<int> implementation
 public void SyntaxError(IRecognizer recognizer, int offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     throw new ArgumentException("Invalid Expression: {0}", msg, e);
 }
コード例 #38
0
 void IAntlrErrorListener <int> .SyntaxError(TextWriter output, IRecognizer recognizer, int offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     _errorHandler.AddError(line, msg);
 }
コード例 #39
0
 public override void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     throw new MExpSyntaxException(line, msg);
 }
コード例 #40
0
ファイル: PlSqlCompiler.cs プロジェクト: deveel/deveeldb
            public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg,
				RecognitionException e)
            {
                if (receiveMessage != null)
                    receiveMessage(new SqlCompileMessage(CompileMessageLevel.Error, msg, new SourceLocation(line, charPositionInLine)));
            }
コード例 #41
0
 public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     throw new Exception("Unable to complete script execution: " + msg + " on line at :" + line.ToString());
 }
コード例 #42
0
ファイル: CommonToken.cs プロジェクト: sharwell/antlr4cs
 public virtual string ToString(IRecognizer r)
 {
     string channelStr = string.Empty;
     if (channel > 0)
     {
         channelStr = ",channel=" + channel;
     }
     string txt = Text;
     if (txt != null)
     {
         txt = txt.Replace("\n", "\\n");
         txt = txt.Replace("\r", "\\r");
         txt = txt.Replace("\t", "\\t");
     }
     else
     {
         txt = "<no text>";
     }
     string typeString = type.ToString();
     if (r != null)
     {
         typeString = r.Vocabulary.GetDisplayName(type);
     }
     return "[@" + TokenIndex + "," + start + ":" + stop + "='" + txt + "',<" + typeString + ">" + channelStr + "," + line + ":" + Column + "]";
 }
コード例 #43
0
 public override string[] ToStrings(IRecognizer recognizer, int currentState)
 {
     return(new string[] { "[]" });
 }
コード例 #44
0
 public string ToString(IRecognizer recog)
 {
     return(ToString(recog, ParserRuleContext.EmptyContext));
 }
コード例 #45
0
ファイル: ArgumentsProcessor.cs プロジェクト: jmclain/Nmp
		/////////////////////////////////////////////////////////////////////////////

		public ArgumentsProcessor( IScanner scanner, IRecognizer recognizer )
		{
			this.scanner = scanner;
			this.recognizer = recognizer;
		}
コード例 #46
0
            public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
            {
                Span span = new Span();
                if (offendingSymbol != null)
                    span = Span.FromBounds(offendingSymbol.StartIndex, offendingSymbol.StopIndex + 1);

                _errors.Add(new ParseErrorEventArgs(msg, span));

                if (_outputWindow != null)
                {
                    if (msg.Length > 100)
                        msg = msg.Substring(0, 100) + " ...";

                    _outputWindow.WriteLine(string.Format("{0}({1},{2}): {3}", _fileName ?? recognizer.InputStream.SourceName, line, charPositionInLine + 1, msg));
                }

                if (_errors.Count > 100)
                    throw new OperationCanceledException();
            }
コード例 #47
0
		public override string[] ToStrings(IRecognizer recognizer, int currentState)
        {
            return new string[] { "[]" };
        }
コード例 #48
0
 public void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     throw new CompilerException(offendingSymbol, "wow, many syntax error: {0}", msg);
 }
コード例 #49
0
 /// <summary>
 /// Creates the recognition with a givern recognizer.
 /// </summary>
 /// <param name="recognizer">the recognizer that will be used for matching the movement with a gesture template</param>
 /// <returns></returns>
 public static IGestureRecognition Create(IRecognizer recognizer)
 {
     var controller = new TrameGestureController(recognizer);
     return new Implementation.GestureRecognition(controller);
 }
コード例 #50
0
 public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     // adding 1 to line, because line is 0-based, but it's 1-based in the VBE
     throw new SyntaxErrorException(msg, e, offendingSymbol, line, charPositionInLine + 1, CodeKind);
 }
コード例 #51
0
ファイル: HScriptProcessor.cs プロジェクト: pwdlugosz/Horse
        public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
        {
            
            string message = string.Format("Invalid token '{0}' found on line '{1}' at position '{2}'", offendingSymbol.Text.ToString(), line, charPositionInLine);
            throw new HScriptException(message, e);

        }
コード例 #52
0
 public FaceController(IClassifier classifier, IRecognizer recognizer)
 {
     _classifier = classifier;
     _recognizer = recognizer;
 }
コード例 #53
0
 public override string[] ToStrings(IRecognizer recognizer, PredictionContext stop, int currentState)
 {
     return(new string[] { "[]" });
 }
コード例 #54
0
 /// <summary>Gets the source input text for a <see cref="ParserRuleContext"/> produced by an <see cref="IRecognizer"/></summary>
 /// <param name="ruleContext">Rule context to get the source text from</param>
 /// <param name="recognizer">Recognizer that produced <paramref name="ruleContext"/></param>
 /// <returns>Source contents for the rule or an empty string if the source is not available</returns>
 public static string GetSourceText(this ParserRuleContext ruleContext, IRecognizer recognizer)
 {
     return(GetSourceText(ruleContext, GetSourceStream(recognizer)));
 }
コード例 #55
0
 public virtual void SyntaxError(IRecognizer recognizer, IToken offendingSymbol
     , int line, int charPositionInLine, string msg, RecognitionException e)
 {
 }
コード例 #56
0
 /// <summary>
 /// <inheritDoc/>
 /// <p>
 /// This implementation prints messages to
 /// <see cref="System.Console.Error"/>
 /// containing the
 /// values of
 /// <paramref name="line"/>
 /// ,
 /// <paramref name="charPositionInLine"/>
 /// , and
 /// <paramref name="msg"/>
 /// using
 /// the following format.</p>
 /// <pre>
 /// line <em>line</em>:<em>charPositionInLine</em> <em>msg</em>
 /// </pre>
 /// </summary>
 public virtual void SyntaxError(TextWriter output, IRecognizer recognizer, Symbol offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     output.WriteLine("line " + line + ":" + charPositionInLine + " " + msg);
 }
コード例 #57
0
 public RecognitionException(Lexer lexer, ICharStream input)
 {
     this.recognizer = lexer;
     this.input = input;
     this.ctx = null;
 }
コード例 #58
0
 public override void SyntaxError(TextWriter output, IRecognizer recognizer, S offendingSymbol, int line,
                                  int col, string msg, RecognitionException e)
 {
     had_error = true;
     base.SyntaxError(output, recognizer, offendingSymbol, line, col, msg, e);
 }
コード例 #59
0
ファイル: LogErrorListener.cs プロジェクト: redxdev/dive
 /// <summary>
 /// Emits a syntax error.
 /// </summary>
 /// <param name="recognizer">The recognizer.</param>
 /// <param name="offendingSymbol">The offending symbol.</param>
 /// <param name="line">The line number.</param>
 /// <param name="charPositionInLine">The character position in the line.</param>
 /// <param name="msg">The error message.</param>
 /// <param name="e">The exception.</param>
 public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     Log.Warn(string.Format("Syntax error at line {0}:{1} - {2}", line, charPositionInLine, msg));
 }
コード例 #60
0
 public override void SyntaxError(System.IO.TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     throw new InvalidOperationException();
 }