~tim/termy

ref: a97a44aca4a4980a8fe33455745831226df96c15 termy/arg_parser.pegjs -rw-r--r-- 391 bytes View raw
a97a44acTim Morgan Fix building of assets for vi 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Expression
  = command:Command args:(Arg)*

Command
  = [^ ]+ { return text() }

Arg
  = _ arg:(DoubleQuotedArg / SingleQuotedArg / BareArg) { return arg }

BareArg
  = ([^ \n] / "\\ ")+ { return text() }
  
DoubleQuotedArg
  = '"' str:('\\"' / [^"])* '"' { return str.join('') }

SingleQuotedArg
  = "'" str:("\\'" / [^'])* "'" { return str.join('') }

_ "whitespace"
  = ([ \t] / "\\\n")*