factor/basis/simple-tokenizer/simple-tokenizer.factor

14 lines
417 B
Factor
Raw Normal View History

! Copyright (C) 2008, 2010 Slava Pestov
2008-03-03 17:45:18 -05:00
! See http://factorcode.org/license.txt for BSD license.
2014-05-23 16:26:29 -04:00
USING: peg.ebnf strings ;
IN: simple-tokenizer
2008-03-03 17:45:18 -05:00
EBNF: tokenize
2009-04-18 22:53:22 -04:00
space = " "
escaped-char = "\" .:ch => [[ ch ]]
quoted = '"' (escaped-char | [^"])*:a '"' => [[ a ]]
unquoted = (escaped-char | [^ "])+
argument = (quoted | unquoted) => [[ >string ]]
command = space* (argument:a space* => [[ a ]])+:c !(.) => [[ c ]]
;EBNF