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);

      }
 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)
             ));
 }
 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;
 }
        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);
        }
 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;
 }
Example #6
0
 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;
        
 }
Example #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;
 }
 public RecognitionException(IRecognizer recognizer, IIntStream input, ParserRuleContext ctx)
 {
     this.recognizer = recognizer;
     this.input = input;
     this.ctx = ctx;
     if (recognizer != null)
     {
         this.offendingState = recognizer.State;
     }
 }
        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
            });

        }
 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();
 }
        /// <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();
        }
        /// <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);
        }
        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;
        }
		/// <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);
					}
				}
			}
		}
Example #15
0
 public override void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     _errorHandler.AddError(line, msg);
 }
Example #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}");
 }
Example #17
0
 /// <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.");
 }
Example #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)
 {
 }
Example #19
0
 public GetNextController(IRecognizer recognizer)
 {
     nm = recognizer.NeuralImage;
 }
Example #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);
 }
 /// <summary>
 /// 
 /// </summary>
 public RecognitionTask(IRecognizer recognizer)
 {
     Recognizer = recognizer;
     recognizer.Initialize(TemplateFactory.CreateTemplates());
 }
 private void CreateMainViewer(IRecognizer <string> recognizer)
 {
     var viewer = new MainViewer <string>(this, recognizer);
 }
Example #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;
        }
Example #24
0
 public virtual void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
 }
Example #25
0
 public virtual string ToString(IRecognizer recog, bool showAlt)
 {
     return(ToString(recog, showAlt, true));
 }
Example #26
0
 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);
 }
Example #27
0
 public override string[] ToStrings(IRecognizer recognizer, PredictionContext stop, int currentState)
 {
     return new string[] { "[]" };
 }
Example #28
0
 public void SyntaxError(TextWriter output, IRecognizer recognizer, int offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     ExceptionList.Add(msg);
 }
		/// <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);
					}
				}
			}
		}
Example #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);
 }
 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));
 }
 /// <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);
 }
        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;
        }
 public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     CompileStatus.AddError(new CompilerError(FileName, line, charPositionInLine, msg));
 }
 /// <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);
 }
Example #36
0
File: ETB.cs Project: 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();
		}
 //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);
 }
Example #38
0
 void IAntlrErrorListener <int> .SyntaxError(TextWriter output, IRecognizer recognizer, int offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
 {
     _errorHandler.AddError(line, msg);
 }
Example #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);
 }
Example #40
0
            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)));
            }
Example #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());
 }
Example #42
0
 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 + "]";
 }
Example #43
0
 public override string[] ToStrings(IRecognizer recognizer, int currentState)
 {
     return(new string[] { "[]" });
 }
Example #44
0
 public string ToString(IRecognizer recog)
 {
     return(ToString(recog, ParserRuleContext.EmptyContext));
 }
Example #45
0
		/////////////////////////////////////////////////////////////////////////////

		public ArgumentsProcessor( IScanner scanner, IRecognizer recognizer )
		{
			this.scanner = scanner;
			this.recognizer = recognizer;
		}
            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();
            }
Example #47
0
		public override string[] ToStrings(IRecognizer recognizer, int currentState)
        {
            return new string[] { "[]" };
        }
Example #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);
 }
 /// <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);
 }
 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);
 }
Example #51
0
        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);

        }
Example #52
0
 public FaceController(IClassifier classifier, IRecognizer recognizer)
 {
     _classifier = classifier;
     _recognizer = recognizer;
 }
Example #53
0
 public override string[] ToStrings(IRecognizer recognizer, PredictionContext stop, int currentState)
 {
     return(new string[] { "[]" });
 }
Example #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)));
 }
 public virtual void SyntaxError(IRecognizer recognizer, IToken offendingSymbol
     , int line, int charPositionInLine, string msg, RecognitionException e)
 {
 }
Example #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);
 }
 public RecognitionException(Lexer lexer, ICharStream input)
 {
     this.recognizer = lexer;
     this.input = input;
     this.ctx = null;
 }
Example #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);
 }
Example #59
0
 /// <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));
 }
Example #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();
 }