diff --git a/Parser/XnParser.cs b/Parser/XnParser.cs index 91f224c..cfb2030 100644 --- a/Parser/XnParser.cs +++ b/Parser/XnParser.cs @@ -188,11 +188,10 @@ namespace XNeedle.Parser public static CommentParser Comment = new CommentParser { Single = "#", NewLine = Environment.NewLine }; - public static readonly Parser BangObject = + public static readonly Parser BangObject = from c1 in Comment.SingleLineComment.Optional() from bang in Parse.Char('!') from name in Parse.AnyChar.Until(Parse.Char('(')) - from bopen in Parse.Char('(') from arguments in Argument.DelimitedBy(Parse.Char(',').Token()) from bclose in Parse.Char(')') let ctx = new Context{XPathSelector = "//*."} @@ -200,7 +199,10 @@ namespace XNeedle.Parser from open in Parse.Char('{') from ws2 in Parse.WhiteSpace.Many().Optional() from c2 in Comment.SingleLineComment.Optional() - from expressions in ExprPart(ctx).Or(Parse.Ref(() => RuleObject)).Or(Parse.Ref(() => BangObject)).DelimitedBy(Parse.Char(';').Token()) + from expressions in Parse.Ref(() => BangObject) + .Or(Parse.Ref(() => RuleObject)) + .Or(ExprPart(ctx).Select(e => (Part)e)) + .DelimitedBy(Parse.Char(';').Token()) from tailingsemi in Parse.Char(';').Optional() from ws3 in Parse.WhiteSpace.Many().Optional() from close in Parse.Char('}') @@ -214,10 +216,14 @@ namespace XNeedle.Parser from open in Parse.Char('{') from ws2 in Parse.WhiteSpace.Many().Optional() from c2 in Comment.SingleLineComment.Optional() - from expressions in ExprPart(ctx).Or(Parse.Ref(() => RuleObject)).Or(Parse.Ref(() => BangObject)).DelimitedBy(Parse.Char(';').Token()) + from expressions in Parse.Ref(() => BangObject) + .Or(Parse.Ref(() => RuleObject)) + .Or(ExprPart(ctx).Select(e => (Part)e)) + .DelimitedBy(Parse.Char(';').Token()) from tailingsemi in Parse.Char(';').Optional() from ws3 in Parse.WhiteSpace.Many().Optional() from close in Parse.Char('}') select new Rule{XPathSelector = selector, Body = expressions}; + } } \ No newline at end of file