Ejemplo n.º 1
0
        public override List <PageFragment> Parse(ScriptContext context, ReadOnlyMemory <char> body, ReadOnlyMemory <char> modifiers)
        {
            var quiet = false;

            if (!modifiers.IsEmpty)
            {
                quiet = modifiers.EqualsOrdinal("q") || modifiers.EqualsOrdinal("quiet") || modifiers.EqualsOrdinal("mute");
                if (!quiet)
                {
                    throw new NotSupportedException($"Unknown modifier '{modifiers.ToString()}', expected 'code|q', 'code|quiet' or 'code|mute'");
                }
            }

            var statements = context.ParseCodeStatements(body);

            return(new List <PageFragment> {
                new PageJsBlockStatementFragment(new JsBlockStatement(statements))
                {
                    Quiet = quiet,
                },
            });
        }