Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to choose fsyacc/fslex or FParsec?

I need to parse simple DSL language like the following:

import "library.txt"

def <int, bool, byte> main(int param1, bool param2)
{
    var a = f4(param1); // or var d = f1(f2(f3(f4(param1))));
    var b = f3(a);
    var c = f2(b);
    var d = f1(c);

    return <d, param2, b0>;
}

What is the most suitable tool to parse such kind of language?

like image 301
Evgeny Gavrin Avatar asked Jan 20 '23 04:01

Evgeny Gavrin


2 Answers

Lex/Yacc are usually better for complete languages with complicated grammars. Parsec is faster to work with when you have short semi-simple tasks. I think that for your case, Lex/Yacc would be much more suitable.

like image 196
Ramon Snir Avatar answered Jan 24 '23 23:01

Ramon Snir


You might find this bullet-point comparison of FParsec with parser generator tools (e.g. fslex & fsyacc) and "hand‐written" recursive descent parsers useful for choosing between the available alternatives.

like image 42
Stephan Tolksdorf Avatar answered Jan 24 '23 21:01

Stephan Tolksdorf