Thread overview | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
July 02, 2015 FancyPars | ||||
---|---|---|---|---|
| ||||
Small announcement. I uploaded my parser-generator onto github. It is work in progress and unfinished! I cannot continue working on it anymore. Because it is quite idiomatic D-code. I hope that it will be suitable to beginners. Unfortunately I will not be available to take any questions. Repo-Location : https://github.com/UplinkCoder/fancypars-lite |
July 06, 2015 Re: FancyPars | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Thursday, 2 July 2015 at 14:25:09 UTC, Stefan Koch wrote:
> Small announcement.
>
> I uploaded my parser-generator onto github.
> It is work in progress and unfinished!
How does its design and use differ from Pegged?
|
July 16, 2015 Re: FancyPars | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Monday, 6 July 2015 at 09:22:51 UTC, Per Nordlöw wrote:
> On Thursday, 2 July 2015 at 14:25:09 UTC, Stefan Koch wrote:
>> Small announcement.
>>
>> I uploaded my parser-generator onto github.
>> It is work in progress and unfinished!
>
> How does its design and use differ from Pegged?
The use does not really differ.
The Design however is very diffrent.
instead of templates it generates CTFEable Functions.
|
September 05, 2015 Re: FancyPars | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Thursday, 2 July 2015 at 14:25:09 UTC, Stefan Koch wrote:
> I cannot continue working on it anymore.
Nontheless an unexpected update that makes FancyPars more Feature-complete than than Pegged.
I addded simplistic Left Recursion handling...
but the code is a mess :(
|
September 06, 2015 Re: FancyPars | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Saturday, 5 September 2015 at 19:45:09 UTC, Stefan Koch wrote: > On Thursday, 2 July 2015 at 14:25:09 UTC, Stefan Koch wrote: > > I addded simplistic Left Recursion handling... Interesting. From the readme: > it only compiles with dmd 2.0.66.2 because it exploits a bug in the const-ness type-system However, 2.0.66.2 does not seem to exist [1,2]. Am I overlooking something? Best, Bastiaan. [1] http://downloads.dlang.org/releases/2.x/ [2] https://github.com/D-Programming-Language/dmd/releases?after=v2.067.1-b1 |
September 06, 2015 Re: FancyPars | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bastiaan Veelo | On Sunday, 6 September 2015 at 20:23:40 UTC, Bastiaan Veelo wrote:
>
> However, 2.0.66.2 does not seem to exist [1,2]. Am I overlooking something?
>
Ahh yeah it should be 2.066.1
Thanks for catching that
|
September 14, 2015 Re: FancyPars | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Monday, 6 July 2015 at 09:22:51 UTC, Per Nordlöw wrote:
>
> How does its design and use differ from Pegged?
FWIW, this is what I learned from my first acquaintance with FancyPars (the OP having signalled not to be available for questions). My conclusions may be wrong though.
Running dub produces a vibe.d web server demonstrating the capabilities of FancyPars. This was a bit confusing at first because being a web-app seemed central to the design of FancyPars, but I think it is not. Anyway, the first page shows a large edit field containing an example grammar, and a button "Generate AST". Clicking this button brings up the second page containing D code for the lexer and parser for the given grammar, type definitions for the nodes of the AST, as well as code for printing the AST.
Understanding the source of FancyPars is challenging because the core source, example vibe.d application source and supporting code, as well as generated lexer/parser code are all contained in the same directory and committed in the repository.
The syntax for the grammar definition is different from Pegged, and seems to be inspired by D. It supports a hierarchical structure. It looks powerful, but is undocumented. The example grammar looks like this:
ASTNode {
Identifier @internal {
[a-zA-Z_][] identifier
}
Group @parent {
Identifier name, ? "@" : Identifier[] annotations : "@", "{",
PatternElement[] elements : "," / Group[] groups,
"}"
}
PatternElement @internal {
AlternativeElement @noFirst {
PatternElement[] alternatives : "/"
}
LexerElement {
StringElement {
"\"", char[] string_, "\""
}
NamedChar {
"char", ? "[]" : bool isArray, Identifier name
}
CharRange @internal {
char rangeBegin, ? "-" : char RangeEnd
}
RangeElement {
"[", CharRange[] ranges, "]"
}
LookbehindElement {
"?lb", "(", StringElement str, ")"
}
NotElement {
"!", LexerElement ce
}
}
NamedElement {
Identifier type, ? "[]" : bool isArray, Identifier name,
? bool isArray : ? ":" : StringElement lst_sep
}
ParenElement {
"(", PatternElement[] elements : ",", ")"
}
FlagElement {
"bool", Identifier flag_name
}
QueryElement {
"?", "bool", Identifier flag_name, ":", PatternElement elem
}
OptionalElement {
"?", LexerElement[] ce : ",", ":", PatternElement elem
}
}
}
Its announced support for left-recursion is interesting, and I may decide to play a bit further with it. My objective would be to see if an Extended Pascal to D translating compiler would be feasible.
Cheers,
Bastiaan Veelo.
|
September 14, 2015 Re: FancyPars | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bastiaan Veelo Attachments:
| Nice one, thanks for the info. I just used Pegged to generate an API for a JSON REST service at compile time so I'm still geeking out about the power of D at compile time, but I'm always interested in parsers. On Mon, Sep 14, 2015 at 10:50 AM, Bastiaan Veelo via Digitalmars-d-announce <digitalmars-d-announce@puremagic.com> wrote: > On Monday, 6 July 2015 at 09:22:51 UTC, Per Nordlöw wrote: > >> >> How does its design and use differ from Pegged? >> > > FWIW, this is what I learned from my first acquaintance with FancyPars (the OP having signalled not to be available for questions). My conclusions may be wrong though. > > Running dub produces a vibe.d web server demonstrating the capabilities of FancyPars. This was a bit confusing at first because being a web-app seemed central to the design of FancyPars, but I think it is not. Anyway, the first page shows a large edit field containing an example grammar, and a button "Generate AST". Clicking this button brings up the second page containing D code for the lexer and parser for the given grammar, type definitions for the nodes of the AST, as well as code for printing the AST. > > Understanding the source of FancyPars is challenging because the core source, example vibe.d application source and supporting code, as well as generated lexer/parser code are all contained in the same directory and committed in the repository. > > The syntax for the grammar definition is different from Pegged, and seems to be inspired by D. It supports a hierarchical structure. It looks powerful, but is undocumented. The example grammar looks like this: > > ASTNode { > Identifier @internal { > [a-zA-Z_][] identifier > } > > Group @parent { > Identifier name, ? "@" : Identifier[] annotations : "@", "{", > PatternElement[] elements : "," / Group[] groups, > "}" > } > > PatternElement @internal { > > AlternativeElement @noFirst { > PatternElement[] alternatives : "/" > } > > LexerElement { > > StringElement { > "\"", char[] string_, "\"" > } > > NamedChar { > "char", ? "[]" : bool isArray, Identifier name > } > > CharRange @internal { > char rangeBegin, ? "-" : char RangeEnd > } > > RangeElement { > "[", CharRange[] ranges, "]" > } > > LookbehindElement { > "?lb", "(", StringElement str, ")" > } > > NotElement { > "!", LexerElement ce > } > > } > > NamedElement { > Identifier type, ? "[]" : bool isArray, Identifier name, > ? bool isArray : ? ":" : StringElement lst_sep > } > > ParenElement { > "(", PatternElement[] elements : ",", ")" > } > > FlagElement { > "bool", Identifier flag_name > } > > QueryElement { > "?", "bool", Identifier flag_name, ":", PatternElement elem > } > > OptionalElement { > "?", LexerElement[] ce : ",", ":", PatternElement elem > } > > } > } > > > Its announced support for left-recursion is interesting, and I may decide to play a bit further with it. My objective would be to see if an Extended Pascal to D translating compiler would be feasible. > > Cheers, > Bastiaan Veelo. > |
September 16, 2015 Re: FancyPars | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Thursday, 2 July 2015 at 14:25:09 UTC, Stefan Koch wrote:
>
> I hope that it will be suitable to beginners.
Sounds like you want to share this, but I can't find a licence. In case this turns out to be useful, we would need one :-)
If you want I can prepare a PR for that, just let me know which licence to pick.
Best,
Bastiaan.
|
September 16, 2015 Re: FancyPars | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bastiaan Veelo | On Monday, 14 September 2015 at 08:50:48 UTC, Bastiaan Veelo wrote: > Understanding the source of FancyPars is challenging because the core source, example vibe.d application source and supporting code, as well as generated lexer/parser code are all contained in the same directory and committed in the repository. Sorry about that. The Files that are really interesting are 1. fancy_grammar.d - contains helpers for working with the FancyParsGrammar Definition. 2. fancy_genPars.d - generates a function which parses the output form the generated lexer 3. fancy_genLex.d generates the lexer function. 4. fancy_genAST.d - generates the AST > The syntax for the grammar definition is different from Pegged, and seems to be inspired by D. It supports a hierarchical structure. It looks powerful, but is undocumented. The example grammar looks like this: The Syntax is inspired by D and Pegged. It is going to be extend though and you should consider it unstable. I will document it as it becomes more stable. > Its announced support for left-recursion is interesting, and I may decide to play a bit further with it. My objective would be to see if an Extended Pascal to D translating compiler would be feasible. TransCompilers are what fancyPars is written for. please show me a few examples of your pascal gramamr. might be in pegged or EBNF or something similar. So I can see if there are idioms I should integrate in fp. Thanks for the interest. -- Stefan (Uplink_Coder) Koch |
Copyright © 1999-2021 by the D Language Foundation