pPEG Dingus
date = year '-' month '-' day
year = [1-2][0-9]*3
month = '0'[1-9] / '1'[0-2]
day = [0-3][0-9]
# A simple example to play around with.
# More examples in menu at top.
# This Dingus is only a toy web-page.
# To try your own pPEG grammars use
# the peg-play.mjs command line tool,
# that lets you work on your own files.
date = year '-' month '-' day
year = [1-2][0-9]*3
month = '0'[1-9] / '1'[0-2]
day = [0-3][0-9]
# A simple example to play around with.
# More examples in menu at top.
# This Dingus is only a toy web-page.
# To try your own pPEG grammars use
# the peg-play.mjs command line tool,
# that lets you work on your own files.
2021-02-03
# Equivalent to the regular expression for
# well-formed URI's in RFC 3986.
URI = (scheme ':')? ('//' auth)?
path ('?' query)? ('#' frag)?
scheme = ~[:/?#]+
auth = ~[/?#]*
path = ~[?#]*
query = ~'#'*
frag = ~[ \t\n\r]*
http://www.ics.uci.edu/pub/ietf/uri/#Related
CSV = Hdr Row+
Hdr = Row
Row = field (',' field)* '\r'? '\n'
field = _string / _text / ''
_text = ~[,\n\r]+
_string = '"' (~["] / '""')* '"'
A,B,C
a1,b1,c1
a2,"b,2",c2
a3,b3,c3
json = _ value _
value = Str / Arr / Obj / num / lit
Obj = '{'_ (memb (_','_ memb)*)? _'}'
memb = Str _':'_ value
Arr = '['_ (value (_','_ value)*)? _']'
Str = '"' chars* '"'
chars = ~[\u0000-\u001F"\]+ / '\' esc
esc = ["\/bfnrt] / 'u' [0-9a-fA-F]*4
num = _int _frac? _exp?
_int = '-'? ([1-9] [0-9]* / '0')
_frac = '.' [0-9]+
_exp = [eE] [+-]? [0-9]+
lit = 'true' / 'false' / 'null'
_ = [ \t\n\r]*
{
"answer": 42,
"mixed": [1, 2.3, "a\tstring", true, [4, 5]],
"empty": {}
}
Copyright 2024