
# pon grammar v2

## alphabet

OPEN       =| '('  ;
CLOSE      =| ')'  ;
SEMICOLON  =| ';'  ;
SPACE      =| ' '  ;
TAB        =| '\t' ;
NEWLINE    =| '\n' ;
RETURN     =| '\r' ;
QUOTE      =| '"'  ;
BACKSLASH  =| '\\' ;

## rules

start =| _ pon ;

_ =| whitespace* ;

whitespace =
| SPACE
| TAB
| NEWLINE
| RETURN
| comment
;

comment =| SEMICOLON message* NEWLINE ;

message = !'\n' ;

pon =| OPEN _ string content CLOSE _ ;

string =
| literal
| quote
;

# TODO literal
literal =| printable+ ;

printable =
# ? TAB NEWLINE RETURN
| ' !"#$%&\''
# OPEN CLOSE
| '*+,-./0123456789:'
# SEMICOLON
| '<=>?@'
| 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
| '['
# BACKSLASH
| ']^_`'
| 'abcdefghijklmnopqrstuvwxyz'
| '{|}~'
;

quote =| QUOTE quoted* QUOTE ;

quoted =
| !'"\\'
| '\\' !''
# TODO restrict to utf-8
# .. will probably need /want hex-ranges for that
;

content =
| # epsilon
| string
| pon+
| field+
;

field =| string pon ;
