mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 03:55:29 +00:00
Added grammar/json.peg
This commit is contained in:
parent
75cdfaf350
commit
ebfee4336a
@ -1,6 +1,4 @@
|
||||
#
|
||||
# CSV grammar based on RFC 4180 (http://www.ietf.org/rfc/rfc4180.txt)
|
||||
#
|
||||
|
||||
file <- (header NL)? record (NL record)* NL?
|
||||
header <- name (COMMA name)*
|
||||
|
26
grammar/json.peg
Normal file
26
grammar/json.peg
Normal file
@ -0,0 +1,26 @@
|
||||
# JSON grammar based on RFC 4627 (http://www.ietf.org/rfc/rfc4627.txt)
|
||||
|
||||
json <- object / array
|
||||
|
||||
object <- '{' (member (',' member)*)? '}' { no_ast_opt }
|
||||
member <- string ':' value
|
||||
|
||||
array <- '[' (value (',' value)*)? ']'
|
||||
|
||||
value <- boolean / null / number / string / object / array
|
||||
|
||||
boolean <- 'false' / 'true'
|
||||
null <- 'null'
|
||||
|
||||
number <- < minus int frac exp >
|
||||
minus <- '-'?
|
||||
int <- '0' / [1-9][0-9]*
|
||||
frac <- ('.' [0-9]+)?
|
||||
exp <- ([eE] [-+]? [0-9]+)?
|
||||
|
||||
string <- '"' < char* > '"'
|
||||
char <- unescaped / escaped
|
||||
escaped <- '\\' (["\\/bfnrt] / 'u' [a-fA-F0-9]{4})
|
||||
unescaped <- [\u0020-\u0021\u0023-\u005b\u005d-\u10ffff]
|
||||
|
||||
%whitespace <- [ \t\r\n]*
|
Loading…
Reference in New Issue
Block a user