public void Build(TokenList tokens)
		{
			instructionListToken = tokens.Current;
			if(isStandardSection)
				tokens.Advance(); // only advance past the section token if 

			// if the current token is the name of the instruction list, store it
			if (tokens.Current != null)
				if (tokens.Current.TokenType == TokenType.QuotedString)
				{
					name = tokens.Current.Value;
					tokens.Advance();
				}

			// read each instruction, one by one until the end of the instruction list is reached
			while (tokens.Current != null)
			{
				// if we've reached a token indicating the end of this instruction block, advance past the ending token and return
				if ((!isLoopBlock && Token.IsEnd(tokens.Current)) ||
					(isLoopBlock && Token.IsLoop(tokens.Current)) ||
					(acceptELSEInPlaceOfEND && (Token.IsElse(tokens.Current) || Token.IsElseIf(tokens.Current))))
				{
					// record the type of terminating token then advance past it
					switch (tokens.Current.Value)
					{
						case "else": terminator = TerminatorType.Else; break;
						case "elseif": terminator = TerminatorType.ElseIf; break;
						case "loop": terminator = TerminatorType.Loop; break;
					}
					tokens.Advance();
					return;
				}
				list.Add(TokenParser.BuildInstruction(tokens));
			}
		}
Example #2
0
        public void Build(TokenList tokens)
        {
            instructionListToken = tokens.Current;
            if (isStandardSection)
            {
                tokens.Advance();                 // only advance past the section token if
            }
            // if the current token is the name of the instruction list, store it
            if (tokens.Current != null)
            {
                if (tokens.Current.TokenType == TokenType.QuotedString)
                {
                    name = tokens.Current.Value;
                    tokens.Advance();
                }
            }

            // read each instruction, one by one until the end of the instruction list is reached
            while (tokens.Current != null)
            {
                // if we've reached a token indicating the end of this instruction block, advance past the ending token and return
                if ((!isLoopBlock && Token.IsEnd(tokens.Current)) ||
                    (isLoopBlock && Token.IsLoop(tokens.Current)) ||
                    (acceptELSEInPlaceOfEND && (Token.IsElse(tokens.Current) || Token.IsElseIf(tokens.Current))))
                {
                    // record the type of terminating token then advance past it
                    switch (tokens.Current.Value)
                    {
                    case "else": terminator = TerminatorType.Else; break;

                    case "elseif": terminator = TerminatorType.ElseIf; break;

                    case "loop": terminator = TerminatorType.Loop; break;
                    }
                    tokens.Advance();
                    return;
                }
                list.Add(TokenParser.BuildInstruction(tokens));
            }
        }