Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: pegkit
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (25 sloc) 0.996 kb
/*
TDParseKit Grammar Syntax now supports regular expressions (powered by RegExKit Lite)
So, as a trivial (and useless) example, the following TDPK grammar
specifies a tiny language which allows dates in the format of:
2009-06-21
// the 'date' production is the outermost production in this grammar
date = /\d{4}/ '-' /\d{2}/ '-' /\d{2}/; // will match any sequence of tokens whose `stringValue` property matches these regexes
*/
// separated by two '-' chars
/*
NOTE:
An equivalent grammar could be expressed in many ways. Here's an equivalent grammar
@symbolState = '-';
date = year dash month dash day;
year = /\d{4}/;
month = /\d{2}/;
day = /\d{2}/;
dash = '-';
*/
@symbolState = '-';
date = year dash month dash day;
year = /\d{4}/;
month = /\d{2}/;
day = /\d{2}/;
dash = '-';
Jump to Line
Something went wrong with that request. Please try again.