public SymbolTableEntry Enter(string name) { SymbolTableEntry entry; if (!(entries.TryGetValue(name, out entry))) { entry = new SymbolTableEntry(name); entries.Add(name, entry); } return(entry); }
// <logo-routine-call-command> ::= <identifier> private BaseLogoCommand ParseLogoRoutineCall() { Match(Token.IDENTIFIER); SymbolTableEntry routineEntry = symbolTable.Lookup(scanner.ScanBuffer); SymbolTableRoutineAttribute routineAttribute = null; if (!routineEntry.TryLookupRoutineAttribute(ref routineAttribute)) { SyntaxError(String.Format("Unknown routine name {0}", scanner.ScanBuffer), LogoErrorCode.RoutineCallError); } return(new LogoRoutineCallCommand(scanner.ScanBuffer, routineAttribute.Commands)); }
// <logo-routine-declaration> ::= TO <identifier> <logo-sentences> END <EOF> private void ParseLogoRoutineDeclaration() { Match(Token.TO); Match(Token.IDENTIFIER); SymbolTableEntry entry = symbolTable.Enter(scanner.ScanBuffer); var routineCommands = new Collection <BaseLogoCommand>(); ParseLogoSentences(routineCommands); var routineAttribute = new SymbolTableRoutineAttribute(routineCommands); entry.AddAttribute(routineAttribute); Match(Token.END); DomainEvents.Raise(new LogoRoutineEvent(symbolTable.LookupRoutines())); }