Skip to content

Commit eb7ccd8

Browse files
author
Olivier Chafik
committed
json: fix integral-part
1 parent 218f41f commit eb7ccd8

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

common/json-schema-to-grammar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct BuiltinRule {
5050
std::unordered_map<std::string, BuiltinRule> PRIMITIVE_RULES = {
5151
{"boolean", {"(\"true\" | \"false\") space", {}}},
5252
{"decimal-part", {"[0-9]{1,16}", {}}},
53-
{"integral-part", {"[0] | [1-9] [0-9]{1,15}", {}}},
53+
{"integral-part", {"[0] | [1-9] [0-9]{0,15}", {}}},
5454
{"number", {"(\"-\"? integral-part) (\".\" decimal-part)? ([eE] [-+]? integral-part)? space", {"integral-part", "decimal-part"}}},
5555
{"integer", {"(\"-\"? integral-part) space", {"integral-part"}}},
5656
{"value", {"object | array | string | number | boolean | null", {"object", "array", "string", "number", "boolean", "null"}}},

examples/json_schema_to_grammar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, content: str, deps: list = None):
3636
PRIMITIVE_RULES = {
3737
'boolean' : BuiltinRule('("true" | "false") space', []),
3838
'decimal-part' : BuiltinRule('[0-9]{1,16}', []),
39-
'integral-part': BuiltinRule('[0] | [1-9] [0-9]{1,15}', []),
39+
'integral-part': BuiltinRule('[0] | [1-9] [0-9]{0,15}', []),
4040
'number' : BuiltinRule('("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space', ['integral-part', 'decimal-part']),
4141
'integer' : BuiltinRule('("-"? integral-part) space', ['integral-part']),
4242
'value' : BuiltinRule('object | array | string | number | boolean | null', ['object', 'array', 'string', 'number', 'boolean', 'null']),

examples/server/public/json-schema-to-grammar.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class BuiltinRule {
3434
const PRIMITIVE_RULES = {
3535
boolean : new BuiltinRule('("true" | "false") space', []),
3636
'decimal-part' : new BuiltinRule('[0-9]{1,16}', []),
37-
'integral-part': new BuiltinRule('[0] | [1-9] [0-9]{1,15}', []),
37+
'integral-part': new BuiltinRule('[0] | [1-9] [0-9]{0,15}', []),
3838
number : new BuiltinRule('("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space', ['integral-part', 'decimal-part']),
3939
integer : new BuiltinRule('("-"? integral-part) space', ['integral-part']),
4040
value : new BuiltinRule('object | array | string | number | boolean | null', ['object', 'array', 'string', 'number', 'boolean', 'null']),

tests/test-json-schema-to-grammar.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
106106
boolean ::= ("true" | "false") space
107107
char ::= [^"\\] | "\\" (["\\/bfnrt] | "u" [0-9a-fA-F]{4})
108108
decimal-part ::= [0-9]{1,16}
109-
integral-part ::= [0] | [1-9] [0-9]{1,15}
109+
integral-part ::= [0] | [1-9] [0-9]{0,15}
110110
null ::= "null" space
111111
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
112112
object ::= "{" space ( string ":" space value ("," space string ":" space value)* )? "}" space
@@ -233,7 +233,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
233233
"type": "integer"
234234
})""",
235235
R"""(
236-
integral-part ::= [0] | [1-9] [0-9]{1,15}
236+
integral-part ::= [0] | [1-9] [0-9]{0,15}
237237
root ::= ("-"? integral-part) space
238238
space ::= " "?
239239
)"""
@@ -298,7 +298,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
298298
R"""(
299299
char ::= [^"\\] | "\\" (["\\/bfnrt] | "u" [0-9a-fA-F]{4})
300300
decimal-part ::= [0-9]{1,16}
301-
integral-part ::= [0] | [1-9] [0-9]{1,15}
301+
integral-part ::= [0] | [1-9] [0-9]{0,15}
302302
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
303303
root ::= "[" space string "," space number "]" space
304304
space ::= " "?
@@ -314,7 +314,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
314314
})""",
315315
R"""(
316316
decimal-part ::= [0-9]{1,16}
317-
integral-part ::= [0] | [1-9] [0-9]{1,15}
317+
integral-part ::= [0] | [1-9] [0-9]{0,15}
318318
root ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
319319
space ::= " "?
320320
)"""
@@ -381,7 +381,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
381381
R"""(
382382
decimal-part ::= [0-9]{1,16}
383383
integer ::= ("-"? integral-part) space
384-
integral-part ::= [0] | [1-9] [0-9]{1,15}
384+
integral-part ::= [0] | [1-9] [0-9]{0,15}
385385
item ::= number | integer
386386
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
387387
root ::= "[" space item ("," space item){2,4} "]" space
@@ -555,7 +555,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
555555
additional-value ::= "[" space (number ("," space number)*)? "]" space
556556
char ::= [^"\\] | "\\" (["\\/bfnrt] | "u" [0-9a-fA-F]{4})
557557
decimal-part ::= [0-9]{1,16}
558-
integral-part ::= [0] | [1-9] [0-9]{1,15}
558+
integral-part ::= [0] | [1-9] [0-9]{0,15}
559559
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
560560
root ::= "{" space (additional-kvs )? "}" space
561561
space ::= " "?
@@ -575,7 +575,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
575575
boolean ::= ("true" | "false") space
576576
char ::= [^"\\] | "\\" (["\\/bfnrt] | "u" [0-9a-fA-F]{4})
577577
decimal-part ::= [0-9]{1,16}
578-
integral-part ::= [0] | [1-9] [0-9]{1,15}
578+
integral-part ::= [0] | [1-9] [0-9]{0,15}
579579
null ::= "null" space
580580
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
581581
object ::= "{" space ( string ":" space value ("," space string ":" space value)* )? "}" space
@@ -597,7 +597,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
597597
boolean ::= ("true" | "false") space
598598
char ::= [^"\\] | "\\" (["\\/bfnrt] | "u" [0-9a-fA-F]{4})
599599
decimal-part ::= [0-9]{1,16}
600-
integral-part ::= [0] | [1-9] [0-9]{1,15}
600+
integral-part ::= [0] | [1-9] [0-9]{0,15}
601601
null ::= "null" space
602602
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
603603
object ::= "{" space ( string ":" space value ("," space string ":" space value)* )? "}" space
@@ -638,7 +638,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
638638
additional-kvs ::= additional-kv ( "," space additional-kv )*
639639
char ::= [^"\\] | "\\" (["\\/bfnrt] | "u" [0-9a-fA-F]{4})
640640
decimal-part ::= [0-9]{1,16}
641-
integral-part ::= [0] | [1-9] [0-9]{1,15}
641+
integral-part ::= [0] | [1-9] [0-9]{0,15}
642642
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
643643
root ::= "{" space a-kv ( "," space ( additional-kvs ) )? "}" space
644644
space ::= " "?
@@ -663,7 +663,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
663663
additional-kvs ::= additional-kv ( "," space additional-kv )*
664664
char ::= [^"\\] | "\\" (["\\/bfnrt] | "u" [0-9a-fA-F]{4})
665665
decimal-part ::= [0-9]{1,16}
666-
integral-part ::= [0] | [1-9] [0-9]{1,15}
666+
integral-part ::= [0] | [1-9] [0-9]{0,15}
667667
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
668668
root ::= "{" space (a-kv a-rest | additional-kvs )? "}" space
669669
space ::= " "?
@@ -691,7 +691,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
691691
b-rest ::= additional-kvs
692692
char ::= [^"\\] | "\\" (["\\/bfnrt] | "u" [0-9a-fA-F]{4})
693693
decimal-part ::= [0-9]{1,16}
694-
integral-part ::= [0] | [1-9] [0-9]{1,15}
694+
integral-part ::= [0] | [1-9] [0-9]{0,15}
695695
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
696696
root ::= "{" space a-kv ( "," space ( b-kv b-rest | additional-kvs ) )? "}" space
697697
space ::= " "?
@@ -755,7 +755,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
755755
decimal-part ::= [0-9]{1,16}
756756
foo ::= "{" space (foo-a-kv )? "}" space
757757
foo-a-kv ::= "\"a\"" space ":" space number
758-
integral-part ::= [0] | [1-9] [0-9]{1,15}
758+
integral-part ::= [0] | [1-9] [0-9]{0,15}
759759
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
760760
root ::= alternative-0 | alternative-1
761761
space ::= " "?
@@ -799,7 +799,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
799799
d-kv ::= "\"d\"" space ":" space number
800800
d-rest ::= ( "," space c-kv )?
801801
decimal-part ::= [0-9]{1,16}
802-
integral-part ::= [0] | [1-9] [0-9]{1,15}
802+
integral-part ::= [0] | [1-9] [0-9]{0,15}
803803
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
804804
root ::= "{" space a-kv "," space b-kv ( "," space ( d-kv d-rest | c-kv ) )? "}" space
805805
space ::= " "?
@@ -842,7 +842,7 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
842842
})""",
843843
R"""(
844844
decimal-part ::= [0-9]{1,16}
845-
integral-part ::= [0] | [1-9] [0-9]{1,15}
845+
integral-part ::= [0] | [1-9] [0-9]{0,15}
846846
number ::= ("-"? integral-part) ("." decimal-part)? ([eE] [-+]? integral-part)? space
847847
number- ::= "{" space number-number-kv "}" space
848848
number-kv ::= "\"number\"" space ":" space number-

0 commit comments

Comments
 (0)