]> gitweb.factorcode.org Git - factor.git/blob - basis/simple-tokenizer/simple-tokenizer.factor
calendar.format: make duration>human-readable more human readable
[factor.git] / basis / simple-tokenizer / simple-tokenizer.factor
1 ! Copyright (C) 2008, 2010 Slava Pestov
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: peg.ebnf multiline strings ;
4 IN: simple-tokenizer
5
6 EBNF: tokenize [=[
7 space = [ \t\n\r]
8 escaped-char = "\\" .:ch => [[ ch ]]
9 quoted = '"' (escaped-char | [^"])*:a '"' => [[ a ]]
10 unquoted = (escaped-char | [^ \t\n\r"])+
11 argument = (quoted | unquoted) => [[ >string ]]
12 command = space* (argument:a space* => [[ a ]])+:c !(.) => [[ c ]]
13 ]=]