[Pyparsing] Bringing together ANTLR and PyParsing
Brought to you by:
ptmcg
From: Athanasios A. <ath...@gm...> - 2014-05-06 17:07:07
|
Hello everybody I have been using PyParsing for some time now and after i came across ANTLR, i thought about bringing the two together. That is, specify a parser in ANTLR's meta-language and then have that translated to a set of PyParsing objects. If you have not seen ANTLR before, it looks like this: input: list+; list: SYM_SBL atom (SYM_COMA atom)* SYM_SBR; //Tokens and rules separated by comas effectively means concatenation. atom:number|string; //The usual OR number:NUM; //number is a rule, NUM is a token (Anything that starts with a capital letter is a token else is a rule) string:STR; SYM_SBL:'['; SYM_RBL:']'; SYM_COMA:','; NUM:[0-9]+; STR:'\'' .*? '\''; A preliminary attempt at this transformation can be found at: https://bitbucket.org/aanastasiou/antlr2pyparsing The relevant discussion over at ANTLR's group is available at: https://groups.google.com/forum/#!topic/antlr-discussion/feRPZhfMcpU ANTLR will be generating parsers in Python soon as it seems. The relevant discussion is available at: https://groups.google.com/forum/#!topic/antlr-discussion/sFH5Y0QO4HA But in any case, this transformation would be very useful to have for PyParsing too. I am just wondering if we could perhaps even augment ANTLR's syntax to accommodate PyParsing features (like Group or Suppress) that ANTLR does not know about. What do you think? All the best AA |