Example #1
0
        Ast.Entry _GetTerm(FtlParserStream ps)
        {
            var id = GetTermIdentifier(ps);

            ps.SkipInlineWs();
            ps.ExpectChar('=');

            Ast.SyntaxNode value = null;
            if (ps.IsPeekValueStart())
            {
                ps.SkipIndent();
                value = GetValue(ps);
            }
            else
            {
                throw new ParseException("E0006", id.Name);
            }

            IReadOnlyList <Ast.Attribute> attrs = null;

            if (ps.IsPeekNextLineAttributeStart())
            {
                attrs = GetAttributes(ps);
            }
            return(new Ast.Term(id, value, attrs));
        }
Example #2
0
        Ast.Entry _GetMessage(FtlParserStream ps)
        {
            var id = GetIdentifier(ps);

            ps.SkipInlineWs();
            ps.ExpectChar('=');

            Ast.Pattern pattern = null;
            if (ps.IsPeekValueStart())
            {
                ps.SkipIndent();
                pattern = GetPattern(ps);
            }
            else
            {
                ps.SkipInlineWs();
            }

            IReadOnlyList <Ast.Attribute> attrs = null;

            if (ps.IsPeekNextLineAttributeStart())
            {
                attrs = GetAttributes(ps);
            }

            if (pattern == null && attrs == null)
            {
                throw new ParseException("E0005", id.Name);
            }

            return(new Ast.Message(id, pattern, attrs));
        }
Example #3
0
        IReadOnlyList <Ast.Attribute> GetAttributes(FtlParserStream ps)
        {
            var attrs = new List <Ast.Attribute>();

            while (true)
            {
                ps.ExpectIndent();
                var attr = GetAttribute(ps);
                attrs.Add(attr);

                if (!ps.IsPeekNextLineAttributeStart())
                {
                    break;
                }
            }
            return(attrs);
        }