Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] Follow up on Saturday's Presentation on Recursive Descent Parsing



I wanted to say thank you for your interest last Saturday.

The presentation should probably have had an extra slide briefly explaining FIRST and FOLLOW sets, I will work that in and pass an update on to Alberto so he can put it up on the TLUG site for anyone who is interested.

I would have liked to show you how to evaluate a grammar in ANTLR and find and resolve conflicts, also how ANTLRworks can graphically build the parse tree as it processes input. It probably was too short a time for this subject. Perhaps we can do that at another time.

The script that produces the syntax (railroad) diagrams is on my repo at bitbucket:

https://bitbucket.org/trijezdci/m2r10/src/tip/_GRAMMAR/modula2_syntax_diagrams.tcl

I had adapted this from a script by the SQLite project. I have also documented (within the script) so that others can more easily adapt it to their own grammars/languages.

Last but not least, yesterday, I wrote a DCG (definite clause grammar) to explore Prolog's built-in parsing capabilities. Terminals are presently represented as non-terminals as I am still working on a tokenizer. Prolog can parse input for DCG grammars and output parse trees with a bit of extra work.

Prolog tutorials and books/coursework never go beyond the "man bites dog, dog bites man, dog chases cat, fred likes sally ..." examples with grammars that are not really useful to illustrate real world use and how to solve real world problems. This DCG is for Modula-2 R10 and has just over 900 prolog clauses, which have recursion in place of the * and + operators of EBNF syntax we explored on Saturday.

If anyone is interested to join this sandbox and play around with RD parsing and Prolog, feel free to contact me.

The DCG is on my repo at bitbucket:

https://bitbucket.org/trijezdci/m2r10/src/tip/_GRAMMAR/modula2-dcg.prolog

regards
benjamin

Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links