문제

What is the advantage of using a library like FParsec for parsing text over using plain regular expressions from a .NET language?

도움이 되었습니까?

해결책

FParsec can recognise (at least) context-free grammars whereas regular expressions can only recognise regular languages, at least without using somewhat hacky extensions.

One example of something you can't do with a regular language is bracket matching, i.e. tracking the number of opening and closing brackets and make sure that they match up.

Of course you can emulate this with regular expressions by using them repeatedly, but embedding the behaviour into a single parser is significantly cleaner.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top