otac0n / Pegasus

A PEG parser generator for .NET that integrates with MSBuild and Visual Studio.

Home Page:http://otac0n.com/Pegasus/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

brace in c# string

fsz1987 opened this issue Β· comments

sorry about my poor English πŸ˜…

I was using pegasus to build my text template engine.

I use a double brace to escape one of them, as following:

br = '{{' { "{" }

but an error appeared:

PEG0011 Unterminated code section

it seems the braces inside the code section must be paired. but I think a single brace inside a c# string expression should be legal

for now , I have to write like this to bypass this problem:

br = '{{' { "\x007b" }

but it is really hard to read. so is this a bug ?

Hi, thanks for chiming in.

This is not exactly a bug, but it has been a known issue in Pegasus since the very beginning. (Duplicate of #44)

You'll be happy to hear that I've recently integrated Roslyn into the Pegasus parser, allowing any valid C# to be used in a code section. You can try out the latest release on NuGet, which should work as you expect: https://www.nuget.org/packages/Pegasus/4.0.0-alpha0035

thanks, I'll try that