Matching axiom and rule statements

We can use the same trick to extract useful information from the axiom and rule statements. Let's do a quick experiment for the axiom statement, which consists of the word axiom, a colon, and a symbol. Matching it with the @capture macro is pretty slick as follows:

Matching a rule statement is just as easy. The only difference is that we want to match the original symbol and the corresponding replacement symbol, as shown here:

Once matched, the original and replacement variables are assigned with the corresponding symbols from the rule. We can also observe that the matched variables are symbols rather than strings. As the LModel programming interface requires strings, we will have to perform an additional data conversion from the symbol in the walk function, which will be presented in the Developing the macro for a DSL section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.172.146