Esempio n. 1
0
 /// <summary>
 /// Initialize
 /// </summary>
 public ParserBase(Context context)
 {
     _context = context;
     _parseErrors = new List<LangException>();
     _lexer = new Lexer(string.Empty);
     _lexer.SetContext(_context);
 }
Esempio n. 2
0
 /// <summary>
 /// Convert the script to a series of tokens.
 /// </summary>
 /// <param name="script">The script content or file name</param>
 /// <param name="isFile">Whether or not the script supplied is a filename or actual script content</param>
 /// <returns></returns>
 public List<TokenData> ToTokens(string script, bool isFile)
 {
     List<TokenData> tokens = null;
     if (isFile)
     {
         script = File.ReadAllText(script);
     }
     var lexer = new Lexer(script);
     lexer.SetContext(_context);
     Execute(() =>
     {
         tokens = lexer.Tokenize();
     },
     () => string.Format("Last token: {0}, Line : {1}, Pos : {2} ", lexer.LastToken.Text, lexer.State.Line, lexer.State.LineCharPosition));
     return tokens;
 }
Esempio n. 3
0
 /// <summary>
 /// Initialize
 /// </summary>
 public ParserBase(Context context)
 {
     _context = context;
     _parseErrors = new List<LangException>();
     _lexer = new Lexer();
     _lexer.SetContext(_context);
     _lexer.Init("");
 }
Esempio n. 4
0
 /// <summary>
 /// Initialize the combinator.
 /// </summary>
 /// <param name="lexer">The main lexer</param>
 public virtual void Init(Lexer lexer)
 {
     _lexer = lexer;
 }
Esempio n. 5
0
 /// <summary>
 /// Initialize the combinator.
 /// </summary>
 /// <param name="lexer">The main lexer</param>
 public virtual void Init(Lexer lexer)
 {
     _lexer = lexer;
 }