Beispiel #1
0
 public ListAst(MessageAst first, MessageAst second)
 {
     List = new List <MessageAst> {
         first, second
     };
 }
Beispiel #2
0
 public void Add(MessageAst item)
 {
     List.Add(item);
 }
Beispiel #3
0
        MessageAst ParseMsg(bool endWithEOF)
        {
            MessageAst res = null;

            while (true)
            {
                if (_curToken == _errorToken)
                {
                    return(BuildError());
                }
                if (_curToken == _eOFToken)
                {
                    if (endWithEOF)
                    {
                        if (res == null)
                        {
                            return(new TextAst(""));
                        }
                        return(res);
                    }
                    return(BuildError("Unexpected end of message missing \"}\""));
                }
                MessageAst val = null;
                if (_curToken == _openBracketToken)
                {
                    AdvanceNextToken();
                    val = ParseFormat();
                }
                else if (_curToken == _hashToken)
                {
                    AdvanceNextToken();
                    val = new HashAst();
                }
                else if (_curToken == _closeBracketToken)
                {
                    if (endWithEOF)
                    {
                        return(BuildError("Unexpected \"}\". Maybe you forgot to prefix it with \"\\\"."));
                    }
                    AdvanceNextToken();
                    if (res == null)
                    {
                        return(new TextAst(""));
                    }
                    return(res);
                }
                else
                {
                    _sb.Clear();
                    while (_curToken >= 0)
                    {
                        AppendCurTokenToSb();
                        AdvanceNextToken();
                    }
                    val = new TextAst(_sb.ToString());
                }
                if (IsError(val))
                {
                    return(val);
                }
                if (res == null)
                {
                    res = val;
                }
                else
                {
                    if (res is ListAst)
                    {
                        ((ListAst)res).Add(val);
                    }
                    else
                    {
                        res = new ListAst(res, val);
                    }
                }
            }
        }