这个解析器设计模式被称为什么?使用包含关键字和函数指针的结构数组的解析器?

时间:2022-10-29 20:57:04

I've seen parsers where the the handling of each keyword is controlled by an array of structures containing each keyword and function pointers to how to handle that keyword. What is this pattern called?

我曾见过解析器,每个关键字的处理都由包含每个关键字的结构数组控制,以及如何处理该关键字的函数指针。这种模式叫什么?

Rather than trying to include a vague example here, I'll just point you to my project.

我不打算在这里包含一个模糊的示例,我只是将您指向我的项目。

2 个解决方案

#1


1  

It sounds very much like Table-Driven parsing, which is generally employed by LR parsers.

这听起来很像表驱动的解析,LR解析器通常使用表驱动的解析。

#2


0  

A symbol (keyword) table with procedural attachment?

带有过程附件的符号(关键字)表?

Is this a linear table without any order?

这是一个没有顺序的线性表吗?

I have to say I've never done that. I have built hash tables containing keywords and action pointers. Look up an identifier in the hash table; if hit, call the keyword routine.

我得说我从来没做过。我已经构建了包含关键字和操作指针的哈希表。在散列表中查找标识符;如果命中,调用关键字程序。

#1


1  

It sounds very much like Table-Driven parsing, which is generally employed by LR parsers.

这听起来很像表驱动的解析,LR解析器通常使用表驱动的解析。

#2


0  

A symbol (keyword) table with procedural attachment?

带有过程附件的符号(关键字)表?

Is this a linear table without any order?

这是一个没有顺序的线性表吗?

I have to say I've never done that. I have built hash tables containing keywords and action pointers. Look up an identifier in the hash table; if hit, call the keyword routine.

我得说我从来没做过。我已经构建了包含关键字和操作指针的哈希表。在散列表中查找标识符;如果命中,调用关键字程序。