danieldietrich / xtext-protected-regions

Xtext Protected Regions
danieldietrich.net
12 stars 6 forks source link

Enhance Region Parser by Backtracking Functionality #30

Open danieldietrich opened 12 years ago

danieldietrich commented 12 years ago

Add a model 'Backtrack' Element impl, which reads ahead.

Motivation: Create a parser for MANIFEST.MF files, which extracts the version of specific bundle dependencies. The protected region support could be used to protected the MANIFEST contents but replace the version of specific bundles (fill in regions/generated regions). This would be helpful for release engineering/packaging of tycho projects.

With the re-design of v2.0.0 and the new architecture of the region parser, it is now possible to extend the functionality of the parser without changing it's implementation. Compared to v1.x of xtext-protected-regions, the loc of the parser could be reduced by 86% from 677 lines to just 91 lines (including comments)!

The key to change parser behavior are so called Elements, which are part of the parser model (-> describing the structure of the parser input). Adding new Elements enhance the parser how input is parsed.

Currently there are the following Elemens: