Esempio n. 1
0
        // <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));
        }
Esempio n. 2
0
        // <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()));
        }
Esempio n. 3
0
        public bool TryLookupRoutineAttribute(ref SymbolTableRoutineAttribute routineAttribute)
        {
            bool result = false;

            foreach (SymbolTableAttribute attribute in attributes)
            {
                if (attribute.Type == SymbolType.ROUTINE)
                {
                    routineAttribute = attribute as SymbolTableRoutineAttribute;
                    result           = true;
                }
            }
            return(result);
        }