示例#1
0
 public void Interpret(Cmd cmd)
 {
     try
     {
         if (!map.ContainsKey(cmd.Name.Lexeme))
         {
             throw new InterpretationError($"Command '{cmd.Name.Lexeme}' does not exist");
         }
         Execute(map[cmd.Name.Lexeme], cmd);
     }
     catch (InterpretationError e)
     {
         clti.WriteError(e.Message);
     }
 }
示例#2
0
 public Cmd?Parse(List <Token> ts)
 {
     tokens = ts;
     try
     {
         return(ParseCommand());
     }
     catch (ParseError e)
     {
         clti.WriteError(e.Message);
         return(null);
     }
 }
示例#3
0
 // Lex: string -> List<Token>
 public List <Token> Lex(string s)
 {
     xs = s;
     try
     {
         Scan();
         tokens.Print();
         return(tokens);
     }
     catch (LexError e)
     {
         clti.WriteError(e.Message);
         return(new List <Token>());
     }
 }