Writing a parser

Started by Xcalibor, March 08, 2010, 04:03:38 AM

Previous topic - Next topic

Xcalibor

Greetings all,



I have written a quick 'n' dirty Perl parser for the SGF (Smart Game Format) which is used, among others, to record Go (Igo, Baduk, Weiqi) matches.



Now I'd like to try doing something similar in NewLISP, but I don't want to directly translate the Perl one, but instead try to build something idiomatic...



Is there any examples on how to build a parser in NewLISP? some previous art, even if parsing different document formats?



Thanks and laters

HPW

#1
The infix module is a parser:



http://www.newlisp.org/code/modules/infix.lsp.html">http://www.newlisp.org/code/modules/infix.lsp.html
Hans-Peter

Lutz

#2
... and here is a second example: a JSON parser:



http://www.newlisp.org/syntax.cgi?code/json.lsp.txt">http://www.newlisp.org/syntax.cgi?code/json.lsp.txt

cormullion

#3
... and I suppose Nestor is a parser of sorts



http://unbalanced-parentheses.nfshost.com/downloads/nestor.lsp.txt.html">//http://unbalanced-parentheses.nfshost.com/downloads/nestor.lsp.txt.html



since it parses newLISP source code. I use it to generate the coloured syntax listings you see. I wrote a bit about it:



http://unbalanced-parentheses.nfshost.com/projectnestorpart1">//http://unbalanced-parentheses.nfshost.com/projectnestorpart1