Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Grammar: Support strict UTF-8 strings and be strict regarding numbers #18

Merged
merged 8 commits into from
Aug 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Grammar.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,29 @@
//
// Grammar \Hoa\Json\Grammar.
//
// Provide grammar for JSON. Please, see <http://json.org> or RFC4627.
// Provide grammar for JSON. Please, see <http://json.org>, RFC4627 or RFC7159.
//
// @copyright Copyright © 2007-2016 Hoa community.
// @license New BSD License
//


%pragma lexer.unicode false
%pragma parser.lookahead 0

%skip space [\x20\x09\x0a\x0d]+

%token true true
%token false false
%token null null
//%token string "([\x20-\x21\x23-\x5b-\x{10ffff}]|\\(["\\/bfnrt]|u[0-9a-fA-F]{4}))+"
%token string "(\w|\\(["\\/bfnrt]))+"
%token string "([\x20\x21\x23-\x5b\x5d-\x7f]|[\xc2-\xdf][\x80-\xbf]|(\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xec][\x80-\xbf]{2}|\xed[\x80-\x9f][\x80-\xbf]{2}|[\xee-\xef][\x80-\xbf]{2})|(\xf0[\x90-\xbf][\x80-\xbf]{2}|[\xf1-\xf3][\x80-\xbf]{3}|\xf4[\x80-\x8f][\x80-\xbf]{2})|\\(["\\/bfnrt]))*"
%token brace_ {
%token _brace }
%token bracket_ \[
%token _bracket \]
%token colon :
%token comma ,
%token number \-?(0|[1-9]\d*)(\.\d+)?([eE][\+\-]?\d+)?
%token number \-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][\+\-]?[0-9]+)?

value:
<true> | <false> | <null> | string() | object() | array() | number()
Expand Down
6 changes: 3 additions & 3 deletions Test/Unit/Soundness.php → Test/Integration/Soundness.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\Json\Test\Unit;
namespace Hoa\Json\Test\Integration;

use Hoa\Compiler as LUT;
use Hoa\File;
Expand All @@ -44,14 +44,14 @@
use Hoa\Test;

/**
* Class \Hoa\Json\Test\Unit\Soundness.
* Class \Hoa\Json\Test\Integration\Soundness.
*
* Check soundness of the LL(k) compiler.
*
* @copyright Copyright © 2007-2016 Hoa community
* @license New BSD License
*/
class Soundness extends Test\Unit\Suite
class Soundness extends Test\Integration\Suite
{
public function case_exaustive_json()
{
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name" : "hoa/json",
"description": "The Hoa\\Json library.",
"type" : "library",
"keywords" : ["library", "json", "grammar"],
"keywords" : ["library", "json", "grammar", "rfc4627", "rfc7159"],
"homepage" : "http://hoa-project.net/",
"license" : "BSD-3-Clause",
"authors" : [
Expand Down