Are regular expressions used to build parsers?

后端 未结 8 1781
Happy的楠姐
Happy的楠姐 2020-12-16 15:58

This is just a question out of curiosity since I have been needing to get more and more into parsing and using regex lately.. it seems, for questions I come across in my sea

8条回答
  •  悲哀的现实
    2020-12-16 16:44

    Typically, you use some sort of pattern-matching (not necessarily regular expressions) in a lexer, to turn your stream of characters into a stream of tokens, and have your parser look at those tokens instead of the raw character input.

    If you're looking to produce your own parsers, you're probably better off looking at something like Bison to assist with that.

提交回复
热议问题