public override ExcutableCommand Create(TokenQueue seq, Token first, CompilerApplication context) { List <ExcutableCommand> result = context.context.Results; int i; for (i = result.Count - 1; i >= 0; i--) { if (result[i].keyword.Type == TokenType.MACRO_COMMAND) { break; } } ExcutableCommand[] param = new ExcutableCommand[result.Count - i - 1]; for (int j = param.Length - 1, k = result.Count - 1; j >= 0; j--, k--) { param[j] = result[k]; result.RemoveAt(k); } MacroCommand macro = (MacroCommand)result[i]; macro.content = param; result.RemoveAt(i); macro.CompileMacro(); return(null); }
public override bool Match(Token first, CompilerApplication context) { if (base.Match(first, context) || context.GetMacro(first.Text) != null) { return(true); } return(false); }
public override ExcutableCommand Create(TokenQueue seq, Token first, CompilerApplication context) { context.SetLabel(first.Text, first); LableCommand c = new LableCommand { keyword = first }; return(c); }
public override bool Match(Token first, CompilerApplication context) { TokenQueue tokens = context.context.Tokens; if (tokens.Peek().Text.Equals(":")) { tokens.Peek().Type = TokenType.LABEL; return(true); } return(false); }
public override ExcutableCommand Create(TokenQueue seq, Token first, CompilerApplication context) { if (base.Match(first, context)) { MacroCommand c = (MacroCommand)Clone(); c.keyword = seq.Dequeue(); c.keyword.Type = TokenType.MACRO_COMMAND; c.parameters = seq.DeQueueLine(); context.SetMacro(c.keyword.Text, c); return(c); } return((MacroCommand)Clone(seq, context.GetMacro(first.Text))); }
public override ExcutableCommand Create(TokenQueue seq, Token first, CompilerApplication context) { string key = seq.Dequeue().Text; seq.Dequeue(); Token value = seq.Dequeue(); context.SetEqu(key, value); if (replaced != null) { return(null); } EquTokenQueue queue = new EquTokenQueue(seq.Count, context); foreach (var c in seq) { queue.Enqueue(c); } seq.Clear(); context.context.Tokens = queue; replaced = queue; return(null); }
public EquTokenQueue(int capacity, CompilerApplication _pool) : base(capacity) { this._pool = _pool; }