Lexer.Lex C# (CSharp) Méthode

Lex() public méthode

public Lex ( ) : bool
Résultat bool
    public bool Lex()
    {
	index = 0;
	//Avoiding a overflow of buffer during lookahead
	//Mind that the FileSize is only initialized in the beginning(constructor).
	file = file + "\n";  
	
	while(index < FileSize){	    
	    Token t = GetNextToken();
	    if (t !=null)
		tokens.Enqueue(t);	    
	}
	//This adds the EOFSYM for the Parser
	tokens.Enqueue(new Token(TokenType.EOFSYM));
	
	return success;
	
    }

Usage Example

Exemple #1
0
 public static void Main(string[] args)
 {
     while (true)
     {
         try
         {
             string s = Console.ReadLine();
             Lexer l = new Lexer();
             Parser p = new Parser(l.Lex(s));
             Ast.Chunk c = p.Parse();
             Compiler.Compiler cplr = new SharpLua.Compiler.Compiler();
             LuaFile proto = cplr.Compile(c, "<stdin>");
             Console.WriteLine("compiled!");
             FileStream fs = File.Open("out.sluac", FileMode.Create);
             foreach (char ch in proto.Compile())
             {
                 //Console.WriteLine(ch + " " + (int)ch);
                 fs.WriteByte((byte)ch);
             }
             fs.Close();
             Console.WriteLine("written to out.sluac!");
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
     }
     Console.Write("Press any key to continue . . . ");
     Console.ReadKey(true);
 }
All Usage Examples Of Lexer::Lex