开发者

What is the difference between lex/yacc and fslex/fsyacc?

开发者 https://www.devze.com 2022-12-19 22:42 出处:网络
I\'m learning F# because I\'d like to write a lexer and parser. I have a tiny bit of experience with this sort of processing but re开发者_如何学Goally need to learn it properly as well as F#.

I'm learning F# because I'd like to write a lexer and parser. I have a tiny bit of experience with this sort of processing but re开发者_如何学Goally need to learn it properly as well as F#.

When learning the lexing/parsing functionality of F#, is studying lex and yacc sufficient?

Or are there some differences that means code for lex/yacc will not work with fslex and fsyacc?


I personally found these OcamlLex and OcamlYacc tutorials excellent resources to get started -- easy to follow, and you can translate most everything in those tutorials for FsLex/FsYacc almost verbatim.


Well, with lex and yacc, you put C/C++ code in the 'actions', whereas with fslex and fsyacc you put F# code there, but I presume you know this?

I think they are otherwise based on the same (established/ancient) tokenizing and parsing technologies, so the general structure/behavior of the grammar should be similar, if that's what you're after...

0

精彩评论

暂无评论...
验证码 换一张
取 消