, [AAp2]. (The package [AAp1] and paclet [AAp2] follow closely the exposition in [JF1]. The package [AAp3] provides a "productized" version of the grammar and parsers code in this notebook. )
Load the paclet
In[3]:=
Needs["AntonAntonov`FunctionalParsers`"]
Generation of integer names
The names of specified integers can be easily (and quickly) generated using the built-in function IntegerName. Here are few examples:
Here we generate the parsers using the paclet [AAp2]:
Parser sanity check examples
Here we see that the parser works:
Random sentences
It is useful to see random sentences from the defined integer names grammar. We expect all random sentences to be meaningful integer names.
Tests
In this section we show tests derivation and verification for the grammar (and generated parsers.)
Tokenization function
Create a list of random integers
Make a table with parsing results
Here we verify that get expected results
Tally statistic
Performance tests
In this section we demonstrate the obtained parser-interpreter is faster the built-in ones.
Here are the number of queries:
Here is the timing with the dedicated parsers:
Here is how the results look like:
Here is how the results look like:
Remark: We can see that the dedicated parser provides the parsing results 100 times faster.
References
Articles
[JF1] Jeroen Fokker, Functional parsers. (1997), Advanced Functional Programming: First International Spring School on Advanced Functional Programming Techniques Båstad, Sweden, May 24–30, 1995 Tutorial Text. DOI: 10.1007/3-540-59451-5_1.
Packages
[AAp2] Anton Antonov, FunctionalParsers WL paclet, (2023), Wolfram Language Paclet Repository.