I'd just like to add, the Coco/R parser generator actually helps in both problems here: It has the CONTEXT keyword, LL(1) conflict resolvers (and lets you peek in the token stream), and finally, actually lets you define nested comments :)
Regards, Alex 2011/4/7 Tom Spink <tsp...@gmail.com>: > 2011/4/7 Chris Seaton <ch...@chrisseaton.com>: >> Just be aware that not all grammars can express all languages, and so not >> all parser-generators can parse all languages. GNU Make does not use a >> parser-generator to parse Makefiles - perhaps there's a good reason. You say >> that a lexer for Make would be very context-dependent, and most >> parse-generators don't handle that well at all. > > Good points! But, there are tools available that make > context-sensitive lexing and parsing much easier - flex and bison, for > example. > >> Generally, parsing is a pretty simple problem in the first place and I think >> that parser-generators often introduce more problems than they solve. Why >> can't you nest block comments in C? Because of a limited lexer-generator. > > Well - okay... but you can use a better lexer generator. Writing > lexers and parsers by hand does have it's merits - for both academic > and practical reasons (e.g. at University, I thoroughly enjoyed making > a finite-state-machine based lexer, and writing an LALR parsing table > by hand), but when tools that are purpose built for solving a complex > problem - because in fact parsing /is/ a complex problem - then those > tools should be utilised as an aid to reduce the amount of time you > have to spend debugging and altering your own implementation. > > The reason I say that parsing /is/ a complex problem is because > parsing isn't just about matching input to a specified grammar, it's > also about building a data structure describing what the input is > representing, and giving feedback when the input does not conform to > syntax. Taking into account this, although it seems that all you're > trying to do is recognise input, it's actually quite complicated when > you start having to deal with and process this input. > >> Do a quick google for a Make grammar for Antlr or Jay and see if anyone else >> has managed it. > > I presume you mention this because there aren't any. > > Touche, Chris. ;-) > >> Regards, >> >> Chris Seaton > > -- Tom > _______________________________________________ > Mono-devel-list mailing list > Mono-devel-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-devel-list > _______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list