Exemple #1
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));
        }
Exemple #2
0
        static void SerializePattern(IndentingWriter writer, Ast.Pattern pattern)
        {
            writer.Indent();
            if (pattern.Elements.Any(IncludesNewLine) ||
                pattern.Elements.Any(IsSelectExpression))
            {
                writer.Write('\n');
            }
            else
            {
                writer.Write(' ');
            }

            foreach (var element in pattern.Elements)
            {
                SerializeElement(writer, element);
            }

            writer.Dedent();
        }