Inheritance: Parrot.Nodes.AbstractNode
Esempio n. 1
0
        public StringLiteral(string value, StatementTail tail)
            : base("string", tail)
        {
            if (IsWrappedInQuotes(value))
            {
                ValueType = ValueType.StringLiteral;
                //strip quotes

                const int quoteOffset = 1;
                value = new string(value.ToArray(), quoteOffset, value.Length - (quoteOffset + 1));
            }
            else if (value == "this")
            {
                ValueType = ValueType.Local;
            }
            else if (value == "null" || value == "true" || value == "false")
            {
                ValueType = ValueType.Keyword;
            }
            else
            {
                ValueType = ValueType.Property;
            }

            if (ValueType == ValueType.StringLiteral)
            {
                Values = Parse(value);
            }
        }
Esempio n. 2
0
        public StringLiteral(string value, StatementTail tail) : base("string", tail)
        {
            if (IsWrappedInQuotes(value))
            {
                ValueType = ValueType.StringLiteral;
                //strip quotes

                const int quoteOffset = 1;
                value = new string(value.ToArray(), quoteOffset, value.Length - (quoteOffset + 1));
            }
            else if (value == "this")
            {
                ValueType = ValueType.Local;
            }
            else if (value == "null" || value == "true" || value == "false")
            {
                ValueType = ValueType.Keyword;
            }
            else
            {
                ValueType = ValueType.Property;
            }

            if (ValueType == ValueType.StringLiteral)
            {
                Values = Parse(value);
            }
        }
Esempio n. 3
0
        public Statement(IHost host, string name, StatementTail statementTail)
            : this(host, name)
        {
            if (statementTail != null)
            {
                if (statementTail.Parameters != null)
                {
                    Parameters = statementTail.Parameters;
                }

                //AddAttributes(statementTail.Attributes);
                if (statementTail.Attributes != null)
                {
                    for (int i = 0; i < Attributes.Count; i++)
                    {
                        statementTail.Attributes.Add(Attributes[i]);
                    }
                    Attributes = statementTail.Attributes;
                }

                if (statementTail.Children != null)
                {
                    Children = statementTail.Children;
                }
            }
        }
Esempio n. 4
0
        public Statement(IHost host, string name, StatementTail statementTail)
            : this(host, name)
        {
            if (statementTail != null)
            {
                if (statementTail.Parameters != null)
                {
                    Parameters = statementTail.Parameters;
                }

                //AddAttributes(statementTail.Attributes);
                if (statementTail.Attributes != null)
                {
                    for (int i = 0; i < Attributes.Count; i++)
                    {
                        statementTail.Attributes.Add(Attributes[i]);
                    }
                    Attributes = statementTail.Attributes;
                }

                if (statementTail.Children != null)
                {
                    Children = statementTail.Children;
                }
            }
        }
Esempio n. 5
0
        private Statement GetStatementFromToken(Token identifier, StatementTail tail, Token previousToken = null)
        {
            var value = identifier != null ? identifier.Content : "";
            if (identifier != null)
            {
                switch (identifier.Type)
                {
                    case TokenType.StringLiteral:
                    case TokenType.QuotedStringLiteral:
                        return new StringLiteral(value, tail) { Index = identifier.Index };

                    case TokenType.StringLiteralPipe:
                        return new StringLiteralPipe(value.Substring(1), tail) { Index = identifier.Index };
                }
            }

            if (previousToken != null)
            {
                switch (previousToken.Type)
                {
                    case TokenType.At:
                        return new EncodedOutput(value) { Index = previousToken.Index };
                    case TokenType.Equal:
                        return new RawOutput(value) { Index = previousToken.Index };
                }
            }

            return new Statement(value, tail) { Index = identifier.Index };
        }
Esempio n. 6
0
        protected internal void ParseStatementTail(StatementTail statementTail)
        {
            if (statementTail != null)
            {
                if (statementTail.Parameters != null)
                {
                    Parameters = statementTail.Parameters;
                }

                //AddAttributes(statementTail.Attributes);
                if (statementTail.Attributes != null)
                {
                    foreach (Attribute attribute in Attributes)
                    {
                        statementTail.Attributes.Add(attribute);
                    }
                    Attributes = statementTail.Attributes;
                }

                if (statementTail.Children != null)
                {
                    Children = statementTail.Children;
                }
            }
        }
Esempio n. 7
0
        private StatementTail ParseSingleStatementTail(Stream stream, StatementTail tail)
        {
            var statementList = ParseStatement(stream);
            //Parrot.Debugger.Debug.WriteLine("Found Single statement tail");
            if (tail == null)
            {
                tail = new StatementTail();
            }
            tail.Children = statementList;

            return tail;
        }
Esempio n. 8
0
 public EncodedOutput(string variableName, StatementTail tail) : base("\"@" + variableName + "\"", tail)
 {
 }
Esempio n. 9
0
 public EncodedOutput(string variableName, StatementTail tail)
     : base("\"@" + variableName + "\"", tail)
 {
 }
Esempio n. 10
0
 public RawOutput(string variableName, StatementTail tail) : base("\"=" + variableName + "\"", tail)
 {
 }
Esempio n. 11
0
        protected internal void ParseStatementTail(StatementTail statementTail)
        {
            if (statementTail != null)
            {
                if (statementTail.Parameters != null)
                {
                    Parameters = statementTail.Parameters;
                }

                //AddAttributes(statementTail.Attributes);
                if (statementTail.Attributes != null)
                {
                    foreach (Attribute attribute in Attributes)
                    {
                        statementTail.Attributes.Add(attribute);
                    }
                    Attributes = statementTail.Attributes;
                }

                if (statementTail.Children != null)
                {
                    Children = statementTail.Children;
                }
            }
        }
Esempio n. 12
0
 public Statement(string name, StatementTail statementTail)
     : this(name)
 {
     ParseStatementTail(statementTail);
 }
Esempio n. 13
0
 public Statement(string name, StatementTail statementTail) : this(name)
 {
     ParseStatementTail(statementTail);
 }
Esempio n. 14
0
 public RawOutput(string variableName, StatementTail tail)
     : base("\"=" + variableName + "\"", tail)
 {
 }