4

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?

ChaosPandion
  • 77,506
  • 18
  • 119
  • 157
Evgeny Gavrin
  • 7,627
  • 1
  • 22
  • 27
  • 2
    If you go with FsYaac/FsLex then I highly recommend the [F# Parsed Language Starter](http://visualstudiogallery.msdn.microsoft.com/a075ff98-7e6f-47ce-a23c-838c1e488046/) template - it avoids having to play around with the command prompt. – Samuel Jul 21 '11 at 16:43

3 Answers3

4

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.

Ramon Snir
  • 7,520
  • 3
  • 43
  • 61
4

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.

Stephan Tolksdorf
  • 3,062
  • 21
  • 28
1

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

I would use active patterns.

J D
  • 48,105
  • 13
  • 171
  • 274