Merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Matthias Brantner
Approved revision: 11156
Merged at revision: 11332
Proposed branch: lp:~paul-lucas/zorba/pjl-misc
Merge into: lp:zorba
Diff against target: 89 lines (+57/-0)
3 files modified
src/runtime/json/jsonml_array.cpp (+45/-0)
test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.spec (+1/-0)
test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.xq (+11/-0)
To merge this branch: bzr merge lp:~paul-lucas/zorba/pjl-misc
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Paul J. Lucas Approve
Review via email: mp+156453@code.launchpad.net

Commit message

Now catching (more) invalid JsonML.

Description of the change

Now catching (more) invalid JsonML.

To post a comment you must log in.
lp:~paul-lucas/zorba/pjl-misc updated
11156. By Paul J. Lucas

Now catching (more) invalid JsonML.

Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job pjl-misc-2013-04-02T03-01-57.515Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/runtime/json/jsonml_array.cpp'
2--- src/runtime/json/jsonml_array.cpp 2013-02-07 17:24:36 +0000
3+++ src/runtime/json/jsonml_array.cpp 2013-04-02 02:52:24 +0000
4@@ -62,6 +62,41 @@
5
6 namespace jsonml_array {
7
8+// JsonML grammar
9+// Source: http://www.ibm.com/developerworks/library/x-jsonml/#N10138
10+//
11+// element
12+// = '[' tag-name ',' attributes ',' element-list ']'
13+// | '[' tag-name ',' attributes ']'
14+// | '[' tag-name ',' element-list ']'
15+// | '[' tag-name ']'
16+// | json-string
17+// ;
18+// tag-name
19+// = json-string
20+// ;
21+// attributes
22+// = '{' attribute-list '}'
23+// | '{' '}'
24+// ;
25+// attribute-list
26+// = attribute ',' attribute-list
27+// | attribute
28+// ;
29+// attribute
30+// = attribute-name ':' attribute-value
31+// ;
32+// attribute-name
33+// = json-string
34+// ;
35+// attribute-value
36+// = json-string
37+// ;
38+// element-list
39+// = element ',' element-list
40+// | element
41+// ;
42+
43 void parse( json::parser &p, store::Item_t *result ) {
44 ZORBA_ASSERT( result );
45
46@@ -83,11 +118,21 @@
47 switch ( token.get_type() ) {
48
49 case '[':
50+ if ( expect_what )
51+ throw XQUERY_EXCEPTION(
52+ zerr::ZJPE0006_UNEXPECTED_TOKEN,
53+ ERROR_PARAMS( token )
54+ );
55 PUSH_STATE( in_array );
56 expect_what = expect::element_name;
57 break;
58
59 case '{':
60+ if ( expect_what )
61+ throw XQUERY_EXCEPTION(
62+ zerr::ZJPE0006_UNEXPECTED_TOKEN,
63+ ERROR_PARAMS( token )
64+ );
65 if ( state_stack.empty() )
66 throw XQUERY_EXCEPTION(
67 zerr::ZJPE0010_JSONML_ARRAY_REQUIRES_BRACKET
68
69=== added file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.spec'
70--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.spec 1970-01-01 00:00:00 +0000
71+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.spec 2013-04-02 02:52:24 +0000
72@@ -0,0 +1,1 @@
73+Error: http://www.zorba-xquery.com/errors:ZJPE0006
74
75=== added file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.xq'
76--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.xq 1970-01-01 00:00:00 +0000
77+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.xq 2013-04-02 02:52:24 +0000
78@@ -0,0 +1,11 @@
79+import module namespace json =
80+ "http://www.zorba-xquery.com/modules/converters/json";
81+
82+let $opt :=
83+ <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options">
84+ <json-format value="JsonML-array"/>
85+ </options>
86+let $json := '[ { "x" : "x" } ]'
87+return json:parse( $json, $opt )
88+
89+(: vim:set et sw=2 ts=2: :)

Subscribers

People subscribed via source and target branches