Beispiel #1
0
 static void SerializeFunction(IndentingWriter writer,
                               Ast.Function fun /* it wasn't */)
 {
     writer.Write(fun.Name);
 }
Beispiel #2
0
        Ast.SyntaxNode _GetSelectorExpression(FtlParserStream ps)
        {
            if (ps.CurrentIs('{'))
            {
                return(GetPlaceable(ps));
            }

            var literal = GetLiteral(ps);

            var mtReference = literal as Ast.MessageTermReference;

            if (mtReference == null)
            {
                return(literal);
            }

            var ch = ps.Current;

            if (ch == '.')
            {
                ps.Next();

                var attr = GetIdentifier(ps);
                return(new Ast.AttributeExpression(mtReference, attr));
            }

            if (ch == '[')
            {
                ps.Next();

                if (mtReference is Ast.MessageReference)
                {
                    throw new ParseException("E0024");
                }

                var key = GetVariantKey(ps);

                ps.ExpectChar(']');

                return(new Ast.VariantExpression(literal, key));
            }

            if (ch == '(')
            {
                ps.Next();

                if (!s_fnName.IsMatch(mtReference.Id.Name))
                {
                    throw new ParseException("E0008");
                }

                var args = GetCallArgs(ps);

                ps.ExpectChar(')');

                var func = new Ast.Function(mtReference.Id.Name);
                if (_withSpans)
                {
                    func.AddSpan(mtReference.Span.Start, mtReference.Span.End);
                }

                return(new Ast.CallExpression(func, args.Positional, args.Named));
            }

            return(literal);
        }