开发者

Table-driven lexical analyzer/scanner implementation

Actually I have two questions. If I start writing my own lexical analyzer, parser what architecture it will be? Wha开发者_高级运维t principles should I consider (i.e. Open-Close, loose coupling)?

Next question is about table-driven lexical analyzer implementation. Recently I have written lexical analyzer but it's not a programming pearl. Obviously I've used too straight approach). So does anyone know about how to implement table driven lexical analyzer?


So if you want to build a lexer your goal is a function that returns the next token by "eating" an input-stream.

The best choice is to implement a deterministic-finite-automation. That means you first have to create the table for the DFA. And the function runs through the DFA table and ends at a specific end state and each end state is assigned to a token. So just return that token and you have a table-driven lexer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜