Sorry for reposting, but I copied the wrong link, http://www.antlr.org/grammar/1078018002577/python.tar.gz
Nikos On Tue, Jul 14, 2009 at 5:57 PM, Nick Vlassopoulos <[email protected]>wrote: > Hi Dmitiry, > > I am not sure if this is what you are looking for, but you might want to > have a look > on how the python grammar handles identation. > See for example: > http://www.antlr.org/grammar/1200715779785/Python.g > > Best Regards, > > Nikos > > > On Tue, Jul 14, 2009 at 5:43 PM, Dmitiry Nagirnyak <[email protected]>wrote: > >> Hi, >> >> I am researching possibility to parse HAML syntax to port it to .NET. >> There is project call NHAML but uses Regular Expressions instead of regular >> parser. >> While it is working great it has certain limitations. >> >> So people start thinking about a real parser. And years ago I did some >> wotks with ANTLR and have chance to revisit it. >> >> My question is about whitespaces. >> In NHAML whitespaces are significant at the beginning of line. >> >> What I would like to have is this (star* for whitespace): >> >> %A >> **%B >> ****%B1 >> ****%B2 >> **%C >> ****%C1 >> >> It would correspond to the tree sam type of tree (A in the root; B,C - >> second level nodes, B1,B22, C1 - third level nodes). >> >> It would be easy if the whitespaces would always be indented at the sane >> number (here 2). >> But this should be configurable. And even more, instead of whitespaces >> there might be tabs. But let's skip this for now. >> >> So grammar like this (just a quick draft) won't satisfy that: >> nhaml : line* >> ; >> line : indent? rule >> ; >> indent : WS WS indent? // How to consume different number of WSs >> depending on provided settings? >> ; >> rule : ~WS (~NL)* >> ; >> >> So the actual question is in rule "indent". >> If I don't know required number of matches of WS during development, how >> can I write grammar for that? >> >> Cheers, >> Dmitriy Nagirnyak. >> >> >> List: http://www.antlr.org/mailman/listinfo/antlr-interest >> Unsubscribe: >> http://www.antlr.org/mailman/options/antlr-interest/your-email-address >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
