GSoC/GCI Archive
Google Code-in 2013 Apertium

Create a program to generate a skeleton bison grammar from an XML description

completed by: Dalimil Hájek

mentors: Mikel L. Forcada, Francis Tyers, Kirill Krylov

Take as input an XML file in .t1x format. Output a skeleton bison grammar where the def-cats are output as %token declarations.

Example:

 

%{
#include <cstdio>
#include <iostream>
using namespace std;

extern "C" int yylex();
extern "C" int yyparse();
extern "C" FILE *yyin;

void yyerror(const char *s);
%}

%union {
    char *sval;
}

%token <sval> num

...

%%

/* fill in grammar here */

%%

main() {
    do {
        yyparse();
    } while (!feof(yyin));

}

void yyerror(const char *s) {
    cout << "EEK, parse error!  Message: " << s << endl;
    // might as well halt now:
    exit(-1);
}