s.wonton.1.29.source-code.wonton.ebnf Maven / Gradle / Ivy
/*
* Copyright (C) 2015 fuwjax.org ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$start: wonton
$ignore: skip
wonton: value | array | object
value: '[' ']'
= []
value: '[' array ']'
= array
value: '{' '}'
= {}
value: '{' object '}'
= object
value: 'null'
= null()
value: 'true'
= true()
value: 'false'
= false()
value: number
= numberOf(number)
value: string | literal
array: value (','? value)*
= [] + value
object: entry (','? entry)*
= {} + entry
entry: key [:=] value
= { key: value }
key: string | literal
string: /'*'/
= "" + schar
string: /"*"/
= "" + dchar
schar: [^//'] | escape
dchar: [^//"] | escape
escape: '\\n'
= '\n'
escape: '\\r'
= '\r'
escape: '\\t'
= '\t'
escape: /\\u<$.unicode.hex4>/
= $.unicode.hex4
escape: /\\U<$.unicode.hex8>/
= $.unicode.hex8
escape: /\\/
= echar
echar: ["'\\]
number: $.number.decimal.int | $.number.decimal.float
literal: /[^:=\[\]{},'"\\#[ws]]+/
skip: comment | ws
comment: /#[^\n]*\n/
ws: $.unicode.class.whitespace
wonton: value | array | object
value: '[' array? ']' | '{' object? '}' | 'null' | 'true' | 'false' | string | number | literal
array: value (','? value)*
object: entry (','? entry)*
entry: key [:=] value
key: string | literal
string: /''|""/
schars: /([^//']|)*/
dchars: /([^//"]|)*/
escape: /\\([nrt]|u{4}|U{8}|["'\\])/
hex: [0-9a-fA-F]
number: /((0|-?[1-9]\d*)(\.\d*)?|-?\.\d+)([eE](0|-?[1-9]\d*))?/
literal: /[^:=\[\]{},'"\\#[ws]]+/
skip: comment | ws
comment: '#' [^\n]* '\n'
ws: [\u0009\u000A-\u000D\u0020\u0085\u00A0\u1680\u2000-\u200B\u2028\u2029\u202F\u205F\u3000]