I've done some experimenting with ANTLR, and it's actually pretty promising. My efforts are in file "sweet.g" in the devel branch.
Comments?? I'd love to hear thoughts on this approach. A key advantage of ANTLR, as expected, is that it can detect a number of errors. I'm sold that a tool is useful in this case, it's detected several problems already (which I fixed). Its parsing-specific debugging mode also makes it easier to find bugs. All tools have their quirks; a key one is that ANTLR strongly separates the lexer semantics from the parser semantics. Of course, bison/yacc + flex/lex do too, but in ANTLR you can put the input in one file. As a convenience, ANTLR will auto-create tokens if it has to (e.g., if you refer to '\n' in a rule). This convenience can bit you: I had a subtle bug because I used '\r' in a rule, which created a separate token for it. For the moment, I think we should just have a reasonable stub for n-expression parsing, and focus on parsing sweet-expressions. The definition of n-expressions is not in doubt, after all. I have a stub for n-expressions so that we can do reasonable testing. I'm presuming that there is an indent parser that creates <,>,and | for DEDENT, INDENT, and SAME. I haven't put in any rules for what's generated, or for EOF; that lets me concentrate on just *accepting* the input to start with. I'm running ANTLRworks, an IDE for ANTLR. To do quick tests I'm using its Run/Debug mode, with input like this: \\ b c(1) >e f < The current one cannot handle block comments if there's NOTHING after them, e.g.: #| stuff #| --- David A. Wheeler ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss