protected void run(Antlr4.Runtime.ICharStream stream) { try { langLexer lexer = new langLexer(stream); ErrorHandler dream_catcher = new ErrorHandler(lexer, this); lexer.RemoveErrorListeners(); lexer.AddErrorListener(dream_catcher); CommonTokenStream tokens = new CommonTokenStream(lexer); langParser parser = new langParser(tokens); parser.RemoveErrorListeners(); parser.AddErrorListener(dream_catcher); Antlr4.Runtime.Tree.IParseTree root = parser.prog(); if (this.can_run) { //foreach (var ins in root_space.instructions) // Console.WriteLine(ins.GetType().Name); ParseTreeWalker walker = new ParseTreeWalker(); walker.Walk(new SiBtyInterpreter(this.root_space), root); this.root_space.exec(); } } catch (Errors.IdentifierError e) { Console.Write("An IdentifierError has been raised :{0}", e.message()); } catch (Errors.NilClassException) { Console.Write("A NilClassError has been raised"); } catch (Errors.OperatorError) { Console.Write("An OperatorError has been raised"); } catch (Errors.ParameterError) { Console.Write("An ParameterError has been raised"); } catch (Errors.VariableError e) { Console.Write("An VariableError has been raise :{0}", e.message()); } catch (Errors.TypeCastingError) { Console.Write("An TypeCastingError has been raised"); } catch (System.Collections.Generic.KeyNotFoundException e) { var stackTrace = new StackTrace(e); Console.Write("An ObjectMemberNotImplementedError has been raised: {0}", stackTrace.GetFrame(1).GetMethod().Name ); } catch (Errors.HashMemberNotFoundError e) { Console.Write("An HashMemberNotFoundError has been raised: {0}", e.message() ); } }
public LexerAdaptor( Antlr4.Runtime.ICharStream input, System.IO.TextWriter output, System.IO.TextWriter errorOutput) : base(input, output, errorOutput) { _input = input; }
/// <summary> /// Creator from a stream reader /// </summary> /// <param name="buffer"></param> public Reader(System.IO.StreamReader reader, String delimiter = null) { _input = new Antlr4.Runtime.AntlrInputStream(reader); if (delimiter != null) { this.Delimiter = delimiter; } }
private String _delimiter = ";"; // Optional Delimiter /// <summary> /// Creator from a string buffer /// </summary> /// <param name="buffer"></param> public Reader(String buffer, String delimiter = null) { _input = new Antlr4.Runtime.AntlrInputStream(buffer); if (delimiter != null) { this.Delimiter = delimiter; } }
public LexerAdaptor( Antlr4.Runtime.ICharStream input, System.IO.TextWriter output, System.IO.TextWriter errorOutput) : base(input, output, errorOutput) { _input = input; PushMode(FlexLexer.INITIAL); }