Skip to content

enhancements Parser

robertwb edited this page · 1 revision
Clone this wiki locally

## page was renamed from enhancements/AutoGenParser ## page was renamed from enhancements/AutoGenParser Autogenerated parser

CEP 902 - Build parser from grammar file

  • Status: Wanted
  • Implementation status: Prototyped
  • Comments: This is part of FabrizioM's GSoC 2008 project proposal

The idea is to genereate the parser starting from the Python standard definition Grammar

# Python24.gra
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
while_stmt: 'while' test ':' suite ['else' ':' suite]
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
try_stmt: ('try' ':' suite
           ((except_clause ':' suite)+
        ['else' ':' suite]
        ['finally' ':' suite] |
       'finally' ':' suite))

the main benefit is that you don't need to modify the parser code by hand. This is not much a issue from python 2.3 to 2.5 but think to [:enhancements/3000: Python3000] support where Grammar change slightly more. The Full [:enchancements/FullPython2.5: Python2.5] Task will benefit from this stage. You generate the parser from a grammar file

parser = build_parser ('Python24.gra')

All this machinery is already done.

  • ([:enhancements/Parser/Status: Status])
  • [:enhancements/Parser/Grammar: Cython Grammar File]

A new grammar is can be found at

Something went wrong with that request. Please try again.