Skip to content
This repository
tag: 0.6
Fetching contributors…

Cannot retrieve contributors at this time

file 52 lines (27 sloc) 1.074 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
/*

    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


@start = date; // 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 = '-';

@start = date;

date = year dash month dash day;

year = /\d{4}/;
month = /\d{2}/;
day = /\d{2}/;

dash = '-';

*/

@symbolState = '-';

@start = date;

date = year dash month dash day;

year = /\d{4}/;
month = /\d{2}/;
day = /\d{2}/;

dash = '-';
Something went wrong with that request. Please try again.