@{% const moo = require("moo"); // I'm not bothering to make each of these tokenizers full proof as I'm assuming the input // will be an actual list of problems. const lexer = moo.compile({ sectionNum: /[1-9]+\.[0-9]+/, date: /[0-9]+\/[0-9]+/, number: /[0-9]+/, newline: {match: '\n', lineBreaks: true}, comment: /\([A-Za-z0-9\,]+\)/ }); %} @lexer lexer Sourcefile -> (Line "\n"):+ Line -> LineLabel "- " LineContents LineLabel -> Section " " DueDate Section -> "Section " %sectionNum DueDate -> "(Due " %date ")" LineContents -> "#" Problems Problems -> (Problem ", "):+ Problem Problem -> RequiredProblem | NotRequiredProblem RequiredProblem -> %number "*" NotRequiredProblem -> %number