I am exploring the SmaCC package (using it to parse Java source files), but I am greatly lacking in my understanding of parsers and scanners. My question is hopefully a simple one... Once I have parsed or just scanned the source, what can I do with it? There is a collection of SmaCCTokens returned via JavaParser class>>parse: but I don't know what to do with them. They seem to be coded in some way but I have no idea how to interpret the codes.
Does anyone have a short tutorial they can point me to? The pages on the SWiki aren't very helpful and the tutorial on refactory.com isn't very helpful either.
Does anyone have a short tutorial they can point me to? The pages on the SWiki aren't very helpful and the tutorial on refactory.com isn't very helpful either.
Put code into the { }-blocks to build a abstract-syntax-tree (AST) from your parsed source. Unfortunately the examples coming with SmaCC don't do this, but actually this is the most common thing to do when parsing. A lot of fancy stuff can then be done by walking over the AST with visitors.
Have a look at the parsers and visitors that I wrote in SmallWiki-Parser (http://map1.squeakfoundation.org/sm/package/5a8df662-642d-4d2a-a093-5efa5878...) or FunctionalPatternMatching (http://map1.squeakfoundation.org/sm/package/3772b420-ba02-4fbd-ae30-8eadfc32...) on SqueakMap.
Hope this helps, Lukas
Am 26.11.2004 um 17:47 schrieb Jason Rogers:
I am exploring the SmaCC package (using it to parse Java source files), but I am greatly lacking in my understanding of parsers and scanners. My question is hopefully a simple one... Once I have parsed or just scanned the source, what can I do with it? There is a collection of SmaCCTokens returned via JavaParser class>>parse: but I don't know what to do with them. They seem to be coded in some way but I have no idea how to interpret the codes.
Does anyone have a short tutorial they can point me to? The pages on the SWiki aren't very helpful and the tutorial on refactory.com isn't very helpful either.
You can look at Anthony's ClosureCompiler for a nice example of how to use SmaCC. (The SmaCC bases Scanner/Parser is in Package "Compiler" on SqueakMap)
Marcus
squeak-dev@lists.squeakfoundation.org