Interpreter.ProcessLine C# (CSharp) Method

ProcessLine() public method

public ProcessLine ( string line ) : bool
line string
return bool
    public bool ProcessLine(string line) {
     // Statements inside braces will be compiled together
        if (line == null)
            return false;
        if (line == "")
            return true;        
        if (line[0] == '/') {
            ProcessCommand(line);
            return true;
        }
        sb.Append(line);
        // ignore {} inside strings!  Otherwise keep track of our block level
        bool insideQuote = false;
        for (int i = 0; i < line.Length; i++) {
            if (line[i] == '\"')
                insideQuote = ! insideQuote;
            if (! insideQuote) {
                if (line[i] == '{') bcount++; else
                if (line[i] == '}') bcount--;
            }
        }
        if (bcount == 0) {            
            string code = sb.ToString();
            sb = new StringBuilder();
            if (code != "")
                ExecuteLine(code);            
        }
        return true;
    }
    

Usage Example

Ejemplo n.º 1
0
 public static void Main(string [] args) {
     Interpreter.Console = new TextConsole();
     Utils.Write(caption+"\n"+prompt);        
     Interpreter interp = new Interpreter();        
     string defs = args.Length > 0 ? args[0] : interp.DefaultIncludeFile();
     interp.ReadIncludeFile(defs);        
     while (interp.ProcessLine(Utils.ReadLine())) 
         Utils.Write(interp.BlockLevel > 0 ? block_prompt : prompt);
 }
All Usage Examples Of Interpreter::ProcessLine