[Pkg-ocaml-maint-commits] [yojson] 02/08: Imported Upstream version 1.2.0

Stéphane Glondu glondu at moszumanska.debian.org
Fri Sep 11 13:55:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

glondu pushed a commit to branch master
in repository yojson.

commit 6f76d8f75b0555f2c2f5dfa9359eabb4d0cabcf5
Author: Stephane Glondu <steph at glondu.net>
Date:   Thu Sep 10 11:56:35 2015 +0200

    Imported Upstream version 1.2.0
---
 Changes  |  17 ++++++
 Makefile |   2 +-
 read.mli |   1 +
 read.mll | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 214 insertions(+), 3 deletions(-)

diff --git a/Changes b/Changes
index 65bb055..7419d87 100644
--- a/Changes
+++ b/Changes
@@ -9,6 +9,23 @@ bug = bug or security fix
 doc = major changes in the documentation
 pkg = changes in the structure of the package or in the installation procedure
 
+2014-12-26 1.2.0: [+ui] new function Yojson.Safe.buffer_json for saving
+                        a raw JSON string while parsing in order to
+                        parse later
+
+2014-01-19 1.1.8: [pkg] cmxs is now generated for supported platforms
+
+2013-05-24 1.1.7: [bug] tolerate double quoted boolean "true" and
+                        "false" when a boolean is expected
+
+2013-05-16 1.1.6: [bug] fix a bug in float printing. now print number
+                        of significant figures rather than decimal
+                        places for write_float_prec and
+                        write_std_float_prec
+
+2013-03-19 1.1.5: [+ui] new function Yojson.sort to sort fields in
+                        objects, and corresponding cmdline option.
+
 2012-12-31 1.1.4: [bug] proper support for escaped code points above U+FFFF
 
 2012-03-19 1.1.3: [+ui] new function Yojson.to_output for writing to an OO
diff --git a/Makefile b/Makefile
index 5d11d5e..681f893 100755
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION = 1.1.8
+VERSION = 1.2.0
 
 ifeq "$(shell ocamlc -config |grep os_type)" "os_type: Win32"
 EXE=.exe
diff --git a/read.mli b/read.mli
index 8543912..8f9502a 100644
--- a/read.mli
+++ b/read.mli
@@ -241,6 +241,7 @@ val read_colon : lexer_state -> Lexing.lexbuf -> unit
 
 val read_json : lexer_state -> Lexing.lexbuf -> json
 val skip_json : lexer_state -> Lexing.lexbuf -> unit
+val buffer_json : lexer_state -> Lexing.lexbuf -> unit
 
 (* end undocumented section *)
 (**/**)
diff --git a/read.mll b/read.mll
index 88eb900..09c0ed1 100644
--- a/read.mll
+++ b/read.mll
@@ -743,7 +743,7 @@ and read_rbr v = parse
   | _        { long_error "Expected ']' but found" v lexbuf }
   | eof      { custom_error "Unexpected end of input" v lexbuf }
 
-(*** And now pretty much the same thing repeated, 
+(*** And now pretty much the same thing repeated,
      only for the purpose of skipping ignored field values ***)
 
 and skip_json v = parse
@@ -841,7 +841,7 @@ and finish_skip_stringlit v = parse
   | _    { long_error "Invalid string literal" v lexbuf }
   | eof  { custom_error "Unexpected end of input" v lexbuf }
 
-and finish_skip_variant v = parse 
+and finish_skip_variant v = parse
     ':'  { skip_json v lexbuf;
 	   read_space v lexbuf;
 	   read_gt v lexbuf }
@@ -855,6 +855,199 @@ and skip_ident v = parse
   | _        { long_error "Expected string or identifier but found" v lexbuf }
   | eof      { custom_error "Unexpected end of input" v lexbuf }
 
+(*** And now pretty much the same thing repeated,
+     only for the purpose of buffering deferred field values ***)
+
+and buffer_json v = parse
+  | "true"
+  | "false"
+  | "null"
+  | "NaN"
+  | "Infinity"
+  | "-Infinity"
+  | '-'? positive_int
+  | float       { add_lexeme v.buf lexbuf }
+
+  | '"'         { finish_buffer_stringlit v lexbuf }
+  | '{'          { try
+                     Bi_outbuf.add_char v.buf '{';
+		     buffer_space v lexbuf;
+		     buffer_object_end v lexbuf;
+		     buffer_ident v lexbuf;
+		     buffer_space v lexbuf;
+		     buffer_colon v lexbuf;
+		     buffer_space v lexbuf;
+		     buffer_json v lexbuf;
+		     while true do
+		       buffer_space v lexbuf;
+		       buffer_object_sep v lexbuf;
+		       buffer_space v lexbuf;
+		       buffer_ident v lexbuf;
+		       buffer_space v lexbuf;
+		       buffer_colon v lexbuf;
+		       buffer_space v lexbuf;
+		       buffer_json v lexbuf;
+		     done;
+		     assert false
+		   with End_of_object ->
+		     ()
+		 }
+
+  | '['          { try
+                     Bi_outbuf.add_char v.buf '[';
+		     buffer_space v lexbuf;
+		     buffer_array_end v lexbuf;
+		     buffer_json v lexbuf;
+		     while true do
+		       buffer_space v lexbuf;
+		       buffer_array_sep v lexbuf;
+		       buffer_space v lexbuf;
+		       buffer_json v lexbuf;
+		     done;
+		     assert false
+		   with End_of_array ->
+		     ()
+		 }
+
+  | '('          {
+                   #ifdef TUPLE
+                     try
+                       Bi_outbuf.add_char v.buf '(';
+		       buffer_space v lexbuf;
+		       buffer_tuple_end v lexbuf;
+		       buffer_json v lexbuf;
+		       while true do
+			 buffer_space v lexbuf;
+			 buffer_tuple_sep v lexbuf;
+			 buffer_space v lexbuf;
+			 buffer_json v lexbuf;
+		       done;
+		       assert false
+		     with End_of_tuple ->
+		       ()
+	           #else
+		     long_error "Invalid token" v lexbuf
+                   #endif
+		 }
+
+  | '<'          {
+                   #ifdef VARIANT
+                     Bi_outbuf.add_char v.buf '<';
+                     buffer_space v lexbuf;
+                     buffer_ident v lexbuf;
+		     buffer_space v lexbuf;
+		     finish_buffer_variant v lexbuf
+                   #else
+                     long_error "Invalid token" v lexbuf
+                   #endif
+		 }
+
+  | "//"[^'\n']* { add_lexeme v.buf lexbuf; buffer_json v lexbuf }
+  | "/*"         { Bi_outbuf.add_string v.buf "/*";
+                   finish_buffer_comment v lexbuf;
+                   buffer_json v lexbuf }
+  | "\n"         { Bi_outbuf.add_char v.buf '\n';
+                   newline v lexbuf;
+                   buffer_json v lexbuf }
+  | space        { add_lexeme v.buf lexbuf; buffer_json v lexbuf }
+  | eof          { custom_error "Unexpected end of input" v lexbuf }
+  | _            { long_error "Invalid token" v lexbuf }
+
+
+and finish_buffer_stringlit v = parse
+    ( '\\' (['"' '\\' '/' 'b' 'f' 'n' 'r' 't'] | 'u' hex hex hex hex)
+    | [^'"' '\\'] )* '"'
+         { Bi_outbuf.add_char v.buf '"';
+           add_lexeme v.buf lexbuf
+	 }
+  | _    { long_error "Invalid string literal" v lexbuf }
+  | eof  { custom_error "Unexpected end of input" v lexbuf }
+
+and finish_buffer_variant v = parse
+    ':'  { Bi_outbuf.add_char v.buf ':';
+           buffer_json v lexbuf;
+	   buffer_space v lexbuf;
+	   buffer_gt v lexbuf }
+  | '>'  { Bi_outbuf.add_char v.buf '>' }
+  | _    { long_error "Expected ':' or '>' but found" v lexbuf }
+  | eof  { custom_error "Unexpected end of input" v lexbuf }
+
+and buffer_ident v = parse
+    '"'      { finish_buffer_stringlit v lexbuf }
+  | ident    { add_lexeme v.buf lexbuf }
+  | _        { long_error "Expected string or identifier but found" v lexbuf }
+  | eof      { custom_error "Unexpected end of input" v lexbuf }
+
+and buffer_space v = parse
+  | "//"[^'\n']* ('\n'|eof)  {
+    add_lexeme v.buf lexbuf;
+    newline v lexbuf;
+    buffer_space v lexbuf }
+  | "/*"                     {
+    Bi_outbuf.add_string v.buf "/*";
+    finish_buffer_comment v lexbuf;
+    buffer_space v lexbuf }
+  | '\n'                     {
+    Bi_outbuf.add_char v.buf '\n';
+    newline v lexbuf;
+    buffer_space v lexbuf }
+  | [' ' '\t' '\r']+         {
+    add_lexeme v.buf lexbuf;
+    buffer_space v lexbuf }
+  | ""                       { () }
+
+and buffer_object_end v = parse
+    '}'      {
+      Bi_outbuf.add_char v.buf '}';
+      raise End_of_object }
+  | ""       { () }
+
+and buffer_object_sep v = parse
+    ','      { Bi_outbuf.add_char v.buf ',' }
+  | '}'      { Bi_outbuf.add_char v.buf '}'; raise End_of_object }
+  | _        { long_error "Expected ',' or '}' but found" v lexbuf }
+  | eof      { custom_error "Unexpected end of input" v lexbuf }
+
+and buffer_array_end v = parse
+    ']'      { Bi_outbuf.add_char v.buf ']'; raise End_of_array }
+  | ""       { () }
+
+and buffer_array_sep v = parse
+    ','      { Bi_outbuf.add_char v.buf ',' }
+  | ']'      { Bi_outbuf.add_char v.buf ']'; raise End_of_array }
+  | _        { long_error "Expected ',' or ']' but found" v lexbuf }
+  | eof      { custom_error "Unexpected end of input" v lexbuf }
+
+and buffer_tuple_end v = parse
+    ')'      {
+      Bi_outbuf.add_char v.buf ')';
+      raise End_of_tuple }
+  | ""       { () }
+
+and buffer_tuple_sep v = parse
+    ','      { Bi_outbuf.add_char v.buf ',' }
+  | ')'      { Bi_outbuf.add_char v.buf ')'; raise End_of_tuple }
+  | _        { long_error "Expected ',' or ')' but found" v lexbuf }
+  | eof      { custom_error "Unexpected end of input" v lexbuf }
+
+and buffer_colon v = parse
+    ':'      { Bi_outbuf.add_char v.buf ':' }
+  | _        { long_error "Expected ':' but found" v lexbuf }
+  | eof      { custom_error "Unexpected end of input" v lexbuf }
+
+and buffer_gt v = parse
+    '>'  { Bi_outbuf.add_char v.buf '>' }
+  | _    { long_error "Expected '>' but found" v lexbuf }
+  | eof  { custom_error "Unexpected end of input" v lexbuf }
+
+and finish_buffer_comment v = parse
+  | "*/" { Bi_outbuf.add_string v.buf "*/" }
+  | eof  { long_error "Unterminated comment" v lexbuf }
+  | '\n' { Bi_outbuf.add_char v.buf '\n';
+           newline v lexbuf;
+           finish_buffer_comment v lexbuf }
+  | _    { add_lexeme v.buf lexbuf; finish_buffer_comment v lexbuf }
+
 and junk = parse
     junk     { Lexing.lexeme lexbuf }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/yojson.git



More information about the Pkg-ocaml-maint-commits mailing list