Skip to main content
QUICK REVIEW

[Paper Review] MediaWiki Grammar Recovery

Vadim Zaytsev|arXiv (Cornell University)|Jul 23, 2011
Natural Language Processing TechniquesComputer Science44 references7 citations
TL;DR

This paper presents a comprehensive recovery and reverse engineering of the MediaWiki grammar from its PHP-based parser, transforming a fragmented, inconsistent, and error-ridden set of grammar fragments into a clean, operational Level 2 grammar in BNF. The result enables reliable parsing, validation, migration, and testing of MediaWiki content across platforms, with future extensions planned for notation standardization, ambiguity resolution, and lexical refinement.

ABSTRACT

The paper describes in detail the recovery effort of one of the official MediaWiki grammars. Over two hundred grammar transformation steps are reported and annotated, leading to delivery of a level 2 grammar, semi-automatically extracted from a community created semi-formal text using at least five different syntactic notations, several non-enforced naming conventions, multiple misspellings, obsolete parsing technology idiosyncrasies and other problems commonly encountered in grammars that were not engineered properly. Having a quality grammar will allow to test and validate it further, without alienating the community with a separately developed grammar.

Motivation & Objective

  • To reverse-engineer and reconstruct the MediaWiki grammar from its PHP-based parser, which was previously fragmented and inconsistent.
  • To produce a clean, operational grammar in BNF format that can be used for parsing, analysis, and transformation of MediaWiki content.
  • To support automated wiki migration, static validation, and parser conformance testing by providing a reliable grammar foundation.
  • To enable future grammar adaptation, notation standardization, and integration with external tools such as Rascal and ANTLR.
  • To address the lack of accessible, correct, and maintainable grammars for wiki markup languages, especially for MediaWiki.

Proposed method

  • Recovery of the grammar from the original PHP source code of the MediaWiki parser, which contained unconnected fragments in multiple notations.
  • Identification and correction of syntactic and semantic errors, including misspellings, missing metasymbols, and inconsistent notation.
  • Transformation of the recovered grammar into a Level 2 BNF grammar, ensuring structural consistency and operational correctness.
  • Preservation and partial reintegration of lexical definitions and entity references from the original source and HTML DTDs.
  • Application of grammar engineering techniques such as grammar adaptation, transformation, and validation to ensure robustness and reusability.
  • Use of formal grammar analysis to detect ambiguities and structural issues, with plans for resolution in future work.

Experimental results

Research questions

  • RQ1How can a large, fragmented, and inconsistent grammar derived from a production parser be reverse-engineered into a coherent, operational formal grammar?
  • RQ2What techniques are effective for recovering and validating a grammar when source documentation is incomplete or incorrect?
  • RQ3How can a recovered grammar be structured to support parsing, migration, validation, and testing across different wiki platforms?
  • RQ4What are the key challenges in transforming a procedural parser implementation into a formal, machine-processable grammar?
  • RQ5How can grammar recovery be extended to include lexical analysis, entity handling, and integration with external formalisms like EBNF or ANTLR?

Key findings

  • The recovered grammar is a clean, consistent, and operational Level 2 BNF grammar, suitable for integration with external tools and further transformation.
  • The original grammar fragments were found to be inconsistent in notation, riddled with errors, and largely unusable without recovery.
  • The recovery process successfully unified disparate grammar fragments and corrected syntactic and semantic inconsistencies.
  • Lexical definitions and HTML entity references were preserved and partially restructured, forming a foundation for a Level 3 grammar.
  • The project demonstrates that grammar recovery from production parser code is feasible and yields a usable, maintainable grammar for wiki content processing.
  • The recovered grammar enables future applications such as static analysis, parser testing, and cross-platform wiki migration.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.