25 lines
875 B
JavaScript
25 lines
875 B
JavaScript
/*
|
|
filename syntax: addr_filename[_colon:separated:tags].ext[.ext]
|
|
addr: sequence of one or more a-p. String.
|
|
filename: anything except underscore or period. String.
|
|
tags: colon-separated list of tags. Array of Strings.
|
|
ext: period, then a-z0-9. Multiple allowed. String, including periods.
|
|
*/
|
|
line = addr:addr name:name tags:tags? ext:ext {return {
|
|
addr: addr.value,
|
|
name: name.value,
|
|
tags: tags?.tags,
|
|
ext: ext.value
|
|
}}
|
|
ext = value:$(("." [a-z0-9]+))+ {return {type: "extension", value}}
|
|
|
|
//tags are separated by colon to allow dashes in values for e.g. dates.
|
|
tags = _ tags:tag|..,":"| {return {type: "tags", tags}}
|
|
tag = $[^:.]+
|
|
addr = value:$[a-p]+ {return {type: "address", value}}
|
|
|
|
//a limitation: filenames may not contain periods.
|
|
//Otherwise it gets more complicated to handle extensions.
|
|
name = _ value:$[^_.]i+ {return {type: "name", value}}
|
|
_ = "_"
|