Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (41 sloc) 2.32 KB
/*****************************************************************************
* *
* Supergrammar.txt *
* 3 May 2010 *
* Project: MetaphysicsIndustries.Giza *
* Written by: Richard Sartor *
* Copyright © 2010-2013 Metaphysics Industries, Inc. *
* *
* The supergrammar - this grammar defines the language used to write *
* other grammars. *
* *
*****************************************************************************/
grammar = ( definition | comment )+;
definition = directive* identifier '=' expr ';';
directive = '<' directive-item ( ',' directive-item )* '>';
directive-item = (
id-mind id-whitespace |
id-ignore id-case |
id-atomic |
id-token |
id-subtoken |
id-comment
);
<mind whitespace, ignore case> id-mind = 'mind';
<mind whitespace, ignore case> id-whitespace = 'whitespace';
<mind whitespace, ignore case> id-ignore = 'ignore';
<mind whitespace, ignore case> id-case = 'case';
<mind whitespace, ignore case> id-atomic = 'atomic';
<mind whitespace, ignore case> id-token = 'token';
<mind whitespace, ignore case> id-subtoken = 'subtoken';
<mind whitespace, ignore case> id-comment = 'comment';
expr = ( subexpr | orexpr | comment )+;
orexpr = '(' expr ( '|' expr )* ')' modifier?;
subexpr = ( identifier | literal | charclass ) modifier? ( ':' identifier:tag )?;
modifier = [*+?];
<mind whitespace, atomic> number = [\d]+;
<mind whitespace, atomic> identifier = [\w-_] [\w-_\d]*;
<mind whitespace> literal = '\'' ( [^\\'] | '\\' [rnt\\'] | unicodechar )+ '\'';
<mind whitespace> charclass = '[' ( [^\\\[\]] | '\\' [wldsrnt\\\[\]] | unicodechar )+ ']';
<mind whitespace, ignore case> unicodechar = '\\x' [\dabcdef][\dabcdef][\dabcdef][\dabcdef];
<mind whitespace> comment = ( '/*' ( [^*] | '*'+ [^*/] )* '*'+ '/' | '//' [^\n]* '\n' );