Replies: 2 comments 2 replies
-
Compile your quasi grammar to DCG rules and then use those, or do you need something even more dynamic? |
Beta Was this translation helpful? Give feedback.
1 reply
-
An interesting problem would be to infer matching grammar (C) from a small sample of different S and D. It would require inductive logic programming. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let's imagine you have a translation task to translate string S into data structure D. For the sake of imagination, let's imagine that S is a binary encoded string similar to (for example) bencode, except that you can configure quasi-types with some configuration C. So for instance, you could specify perhaps a functor with a name, arrity 2, and arg 0 would be a string and arg 1 would be yet another nested functor. How this would be serialized linearly, something like:
and maybe that would all be packed together with a header, length, data for binary serialization.
This is just an example of a possible S. Let's say the desired D was a valid Prolog term. And let's say that there was a configuration C that communicated the valid quasi-types to be parsed from S. In fact, C is really a quasi-grammar.
So, normally, if I were writing a parser, the DCGs themselves would be the grammar. But in this case, I'm wondering how you would write a generic parser with a configurable grammar. Does anyone have any ideas or resources on this?
Beta Was this translation helpful? Give feedback.
All reactions