Beispiel #1
0
        public new static If_Procedure Create(ContinueQueue parsingObject)
        {
            If_Procedure prefab = new If_Procedure();

            Label headLabel = Label.Create(parsingObject);

            // This should be `(`
            parsingObject.Dequeue();
            prefab.Head        = Expression.Create(parsingObject);
            prefab.Head.Parent = prefab;
            // This should be `)`
            parsingObject.Dequeue();
            prefab.Head.Label = headLabel;

            // the next string should be "{", remove it
            parsingObject.Dequeue();

            while (parsingObject.Peek() != "}")
            {
                Label bodyLabel = Label.Create(parsingObject);
                var   temp      = Statement.Create(parsingObject);
                temp.Parent           = prefab;
                temp.Label            = bodyLabel;
                temp.Expression.Label = bodyLabel;

                prefab.Body.Add(temp);
            }

            // remove '}'
            parsingObject.Dequeue();

            prefab.Else = Else_Procedure.Create(parsingObject);

            return(prefab);
        }
Beispiel #2
0
        public static Token Create(ContinueQueue parsingObject)
        {
            Label label = Label.Create(parsingObject);
            Token token = null;

            string content = parsingObject.Dequeue();

            if (!char.IsLetterOrDigit(content[0]))
            {
                char character = content[0];
                switch (character)
                {
                case '(':
                    break;

                case '{':
                    break;

                case '\"':
                    token = FormatString.Create(parsingObject);
                    break;

                //  # Pre-interpretation option. eg. #include <stdlib>
                case '#':
                    token = PreInterpretationStatement.Create(parsingObject);
                    break;

                // // Comment. eg. // Comment
                case '/':
                    if (parsingObject.Peek()[0] == '/')
                    {
                        parsingObject.Dequeue();
                        token = Comment.Create(parsingObject);
                    }
                    break;

                default:
                    break;
                }
            }
            else
            {
                switch (content)
                {
                case "if":
                    token = If_Procedure.Create(parsingObject);
                    break;

                default:
                    break;
                }
            }

            token.Label = label;
            return(token);
        }