fsprojects / FsLexYacc

Lexer and parser generators for F#
http://fsprojects.github.io/FsLexYacc/
MIT License
207 stars 69 forks source link

Invite you to try a new series of Lex/Yacc tools #151

Closed xp44mm closed 2 years ago

xp44mm commented 3 years ago

Lex/Yacc programming enthusiasts, including the maintainers of this repo, I am very pleased to invite you to try a new series of lex/yacc tools. It is a very powerful, easy-to-use next-generation series of Lex/Yacc tools.

The open source see to: xp44mm/FSharpCompiler

The usage of FSharpCompiler.Lex and FSharpCompiler.Analyzing, see the resolution: xp44mm/PolynomialExpressions

The usage of FSharpCompiler.Yacc and FSharpCompiler.Parsing, see the resolution: xp44mm/ArithmeticExpressions

sergey-tihon commented 3 years ago

cc @baronfel

@xp44mm can you briefly explain difference with this repo / benefits of using new one?

xp44mm commented 3 years ago

FSharpCompiler is a generic compiler generator written in F# language.

Its rules do not contain semantic actions, so it is programming language independent. you can use any language you are familiar with to write your compiler.

You can iteratively apply regular expressions or context-free grammar to syntax sequences(input tokens) using combination approachs. Using it is as easy as Regex.

kkm000 commented 3 years ago

@xp44mm, and how does it compare to FParsec?

xp44mm commented 3 years ago

@kkm000, The FSharpCompiler, It is a compiler of lex/yacc syntax, more like fslexyacc.

kkm000 commented 3 years ago

@xp44mm, I see. On the surface, yacc looks like yet another yacc (yayacc, given that "yacc" stands for "yet another compiler compiler"). What's the principal difference?

In the lexer, I could not understand what do you mean by "combination approach" (this is why I asked about FParsec, even before looking). It does not look like a library of combinators.

xp44mm commented 3 years ago

"combination approach" in lex/yacc refers to the combination of lex-generated analyzer or yacc-generated parser. while, the traditional compiler can only be used once in lex-> yacc->ast.

kkm000 commented 3 years ago

@sergey-tihon @baronfel As far as parsing combinators go, I just discovered https://teo-tsirpanis.github.io/Farkle/. I have not played it it yet. Wondering if you know and how good it is. Recently FParsec was my go-to parser (e.g., I used one for the ABNF form defined by WWWC for SRGS grammars). I like it (or maybe just get used to it), but explicitly accepting whitespace may get annoying. I had to define 3 combinators for whitespace in different contexts (e.g., in a file header linefeed is significant; in others any whitespace including LF is optional and in yet others it's not). A source of confusion and errors, indeed.

xp44mm commented 2 years ago

The package FSharpCompiler is legacy and is no longer maintained. Replace this package with the FslexFsyacc package, which implements all the features of this package and is more friendly.

kkm000 commented 2 years ago

Thanks!