public
Description: A simple language for defining todo lists, using the Mg (or MGrammar) language, from Microsoft's Oslo platform.
Homepage:
Clone URL: git://github.com/m4dc4p/mg-todo.git
mg-todo / todo4.mg
100755 38 lines (29 sloc) 1.085 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
module ToDo
{
    // Projecting our tasks into a resonable object
    // model.
    language Tasks4 {
        // Allow an empty task list.
        syntax Main = Line*;
    
        syntax Line = TaskLine | Comment;
        syntax TaskLine = "task" Title DueDate?;
 
        // Allow quoted titles
        syntax Title = SingleQuotedText | DoubleQuotedText;
        syntax DueDate = Month "-" Day "-" Year;
 
        // token used here because syntax causes
        // error. ???
        token Comment = "#" ^('\r' | '\n')*;
        
        token Digit = "0".."9";
        token Month = Digit#1..2;
        token Day = Digit#1..2;
        token Year = Digit#2..4;
 
        token SingleQuotedText = QuotedText('"');
        token DoubleQuotedText = QuotedText("'");
        
        // Parameterized rule.
        token QuotedText(Q) = Q (Text - Q)* Q;
        
        // Inspired by M.mg
        token Text = '"' ^('\n' | '\r')* '"';
        
        // Ignore whitespace
        interleave Whitespace = '\r' | ' ' | '\n';
    }
}