[svn:parrot] r41137 - in trunk: . compilers/data_json compilers/data_json/data_json config/gen config/gen/makefiles tools/dev

japhb at svn.parrot.org japhb at svn.parrot.org
Mon Sep 7 21:07:12 UTC 2009


Author: japhb
Date: Mon Sep  7 21:07:11 2009
New Revision: 41137
URL: https://trac.parrot.org/parrot/changeset/41137

Log:
[data_json] Now with less horribly borken; frob makefile templates, svn properties, manifests, etc. to match

Modified:
   trunk/MANIFEST
   trunk/MANIFEST.SKIP
   trunk/MANIFEST.generated
   trunk/compilers/data_json/   (props changed)
   trunk/compilers/data_json/data_json/   (props changed)
   trunk/compilers/data_json/data_json.pir
   trunk/config/gen/makefiles.pm
   trunk/config/gen/makefiles/data_json.in
   trunk/config/gen/makefiles/root.in
   trunk/tools/dev/install_dev_files.pl

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Mon Sep  7 20:45:05 2009	(r41136)
+++ trunk/MANIFEST	Mon Sep  7 21:07:11 2009	(r41137)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Mon Sep  7 20:43:54 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Mon Sep  7 21:02:37 2009 UT
 #
 # See below for documentation on the format of this file.
 #

Modified: trunk/MANIFEST.SKIP
==============================================================================
--- trunk/MANIFEST.SKIP	Mon Sep  7 20:45:05 2009	(r41136)
+++ trunk/MANIFEST.SKIP	Mon Sep  7 21:07:11 2009	(r41137)
@@ -1,6 +1,6 @@
 # ex: set ro:
 # $Id$
-# generated by tools/dev/mk_manifest_and_skip.pl Tue Jul 21 23:09:08 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Mon Sep  7 21:02:37 2009 UT
 #
 # This file should contain a transcript of the svn:ignore properties
 # of the directories in the Parrot subversion repository. (Needed for
@@ -143,6 +143,16 @@
 ^vc70\.pdb/
 ^vtable\.dump$
 ^vtable\.dump/
+# generated from svn:ignore of 'compilers/data_json/'
+^compilers/data_json/Makefile$
+^compilers/data_json/Makefile/
+^compilers/data_json/data_json\.pbc$
+^compilers/data_json/data_json\.pbc/
+# generated from svn:ignore of 'compilers/data_json/data_json/'
+^compilers/data_json/data_json/.*\.pbc$
+^compilers/data_json/data_json/.*\.pbc/
+^compilers/data_json/data_json/.*\.pir$
+^compilers/data_json/data_json/.*\.pir/
 # generated from svn:ignore of 'compilers/imcc/'
 ^compilers/imcc/.*\.flag$
 ^compilers/imcc/.*\.flag/

Modified: trunk/MANIFEST.generated
==============================================================================
--- trunk/MANIFEST.generated	Mon Sep  7 20:45:05 2009	(r41136)
+++ trunk/MANIFEST.generated	Mon Sep  7 21:07:11 2009	(r41137)
@@ -7,8 +7,9 @@
 blib/lib/libparrot.dylib                          [main]lib
 blib/lib/libparrot.so.1.5.0                       [main]lib
 blib/lib/libparrot.so                             [main]lib
-compilers/json/JSON/grammar.pbc                   [json]
+compilers/data_json/data_json.pbc                 [data_json]
 compilers/json/JSON.pbc                           [json]
+compilers/json/JSON/grammar.pbc                   [json]
 compilers/json/JSON/pge2pir.pbc                   [json]
 compilers/nqp/nqp.pbc                             [nqp]
 config/gen/call_list/opengl.in                    []

Modified: trunk/compilers/data_json/data_json.pir
==============================================================================
--- trunk/compilers/data_json/data_json.pir	Mon Sep  7 20:45:05 2009	(r41136)
+++ trunk/compilers/data_json/data_json.pir	Mon Sep  7 21:07:11 2009	(r41137)
@@ -3,37 +3,43 @@
 
 =head1 NAME
 
-JSON (JavaScript Object Notation) is a lightweight data-interchange format.
+data_json - parse JSON, a lightweight data-interchange format.
 
 =head1 SYNOPSIS
 
-Given a valid JSON string, the compiler will return a PMC containing the
-appropriate values. For example:
+Given a valid JSON (JavaScript Object Notation) string, the compiler will
+return a sub that when called will produce the appropriate values.  For
+example:
+
+    .local pmc json, code, result
+    json   = compreg 'data_json'
+    code   = json.'compile'('[1,2,3]')
+    result = code()
 
- .local pmc JSON
- JSON = compreg 'JSON'
- $P0 = JSON('[1,2,3]')
+will create a PMC that C<does> C<array> containing the values 1, 2, and 3,
+and store it in the C<result>.
 
-Will create a pmc that C<does> array, contains the values 1, 2, and 3, and
-store it in register C<$P0>.
-
-For more information about the structure of the JSON representation, see the
-documentation at L<http://www.json.org/>.
+For more information about the structure of the JSON representation, see
+the documentation at L<http://www.json.org/>.
 
 =cut
 
-.namespace [ 'JSON' ]
+.include 'compilers/data_json/data_json/grammar.pir'
+.include 'compilers/data_json/data_json/pge2pir.pir'
+# .include 'data_json/grammar.pir'
+# .include 'data_json/pge2pir.pir'
+
+
+.HLL 'data_json'
 
 .sub '__onload' :load
     load_bytecode 'PGE.pbc'
     load_bytecode 'PGE/Util.pbc'
     load_bytecode 'TGE.pbc'
 
-    load_bytecode 'compilers/json/JSON/grammar.pbc'
-    load_bytecode 'compilers/json/JSON/pge2pir.pbc'
-
-    $P1 = get_global '__compiler'
-    compreg "JSON", $P1
+    $P1 = newclass ['JSON'; 'Compiler']
+    $P2 = new $P1
+    compreg 'data_json', $P2
 
     $P1 = new 'Hash'
     $P1['\"'] = '"'
@@ -45,35 +51,38 @@
     $P1['\r'] = "\r"
     $P1['\t'] = "\t"
 
-    set_root_global [ 'JSON' ], '$escapes', $P1
+    set_hll_global '$escapes', $P1
 .end
 
-.sub '__compiler'
+
+.namespace ['JSON';'Compiler']
+
+.sub 'compile' :method
     .param string json_string
 
-   .local pmc parse, match
-   parse = get_root_global ['parrot'; 'JSON'], 'value'
+    .local pmc parse, match
+    parse = get_root_global ['parrot'; 'JSON'], 'value'
 
-   $P0 = get_root_global ['parrot'; 'PGE'], 'Match'
-   match = $P0.'new'(json_string)
-   match.'to'(0)
-   match = parse(match)
-   unless match goto failed
-
-   .local pmc pirgrammar, pirbuilder, pir
-   pirgrammar = new ['JSON'; 'PIR']
-   pirbuilder = pirgrammar.'apply'(match)
-   pir = pirbuilder.'get'('result')
-
-   .local pmc pirc, result
-   pirc = compreg "PIR"
-   result = pirc(pir)
-   .tailcall result()
+    $P0 = get_root_global ['parrot'; 'PGE'], 'Match'
+    match = $P0.'new'(json_string)
+    match.'to'(0)
+    match = parse(match)
+    unless match goto failed
+
+    .local pmc pirgrammar, pirbuilder, pir
+    pirgrammar = new ['JSON'; 'PIR']
+    pirbuilder = pirgrammar.'apply'(match)
+    pir = pirbuilder.'get'('result')
+
+    .local pmc pirc, result
+    pirc = compreg 'PIR'
+    result = pirc(pir)
+    .return (result)
 
   failed:
-   $P0 = new 'Exception'
-   $P0[0] = "invalid JSON value"
-   throw $P0
+    $P0 = new 'Exception'
+    $P0[0] = "Invalid JSON value"
+    throw $P0
 .end
 
 # Local Variables:

Modified: trunk/config/gen/makefiles.pm
==============================================================================
--- trunk/config/gen/makefiles.pm	Mon Sep  7 20:45:05 2009	(r41136)
+++ trunk/config/gen/makefiles.pm	Mon Sep  7 21:07:11 2009	(r41137)
@@ -48,6 +48,8 @@
             { SOURCE => 'config/gen/makefiles/tge.in' },
         'compilers/json/Makefile'    =>
             { SOURCE => 'config/gen/makefiles/json.in' },
+        'compilers/data_json/Makefile' =>
+            { SOURCE => 'config/gen/makefiles/data_json.in' },
         'compilers/pirc/Makefile'    =>
             { SOURCE => 'config/gen/makefiles/pirc.in' },
         'src/dynpmc/Makefile'        =>

Modified: trunk/config/gen/makefiles/data_json.in
==============================================================================
--- trunk/config/gen/makefiles/data_json.in	Mon Sep  7 20:45:05 2009	(r41136)
+++ trunk/config/gen/makefiles/data_json.in	Mon Sep  7 21:07:11 2009	(r41137)
@@ -10,14 +10,14 @@
 TGE_DIR  := ../../compilers/tge
 
 # the default target
-all: JSON.pbc
+all: data_json.pbc
 
 # This is a listing of all targets, that are meant to be called by users
 help:
 	@echo ""
 	@echo "Following targets are available for the user:"
 	@echo ""
-	@echo "  all:               JSON.pbc"
+	@echo "  all:               data_json.pbc"
 	@echo "                     This is the default."
 	@echo "Testing:"
 	@echo "  test:              Run the test suite."
@@ -36,23 +36,23 @@
 testclean:
 	$(RM_F) "../../t/compilers/json/*.pir"
 
-JSON.pbc : JSON/grammar.pbc JSON/pge2pir.pbc JSON.pir
-	$(PARROT) --output=JSON.pbc JSON.pir
+data_json.pbc : data_json/grammar.pbc data_json/pge2pir.pbc data_json.pir
+	$(PARROT) --output=data_json.pbc data_json.pir
 
-JSON/grammar.pbc : JSON/grammar.pir
-	$(PARROT) --output=JSON/grammar.pbc JSON/grammar.pir
+data_json/grammar.pbc : data_json/grammar.pir
+	$(PARROT) --output=data_json/grammar.pbc data_json/grammar.pir
 
-JSON/grammar.pir : JSON/grammar.pg
-	$(PARROT) $(TOOL_DIR)/runtime/parrot/library/PGE/Perl6Grammar.pbc --output=JSON/grammar.pir JSON/grammar.pg
+data_json/grammar.pir : data_json/grammar.pg
+	$(PARROT) $(TOOL_DIR)/runtime/parrot/library/PGE/Perl6Grammar.pbc --output=data_json/grammar.pir data_json/grammar.pg
 
-JSON/pge2pir.pbc : JSON/pge2pir.pir
-	$(PARROT) --output=JSON/pge2pir.pbc JSON/pge2pir.pir
+data_json/pge2pir.pbc : data_json/pge2pir.pir
+	$(PARROT) --output=data_json/pge2pir.pbc data_json/pge2pir.pir
 
-JSON/pge2pir.pir : JSON/pge2pir.tg
-	$(PARROT) $(TGE_DIR)/tgc.pir --output=JSON/pge2pir.pir JSON/pge2pir.tg
+data_json/pge2pir.pir : data_json/pge2pir.tg
+	$(PARROT) $(TGE_DIR)/tgc.pir --output=data_json/pge2pir.pir data_json/pge2pir.tg
 
 clean : testclean
-	$(RM_F) "JSON/*.pbc" "JSON/*.pir" JSON.pbc
+	$(RM_F) "data_json/*.pbc" "data_json/*.pir" data_json.pbc
 
 # Local variables:
 #   mode: makefile

Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in	Mon Sep  7 20:45:05 2009	(r41136)
+++ trunk/config/gen/makefiles/root.in	Mon Sep  7 21:07:11 2009	(r41137)
@@ -147,6 +147,7 @@
 GEN_MAKEFILES := \
     Makefile \
     docs/Makefile \
+    compilers/data_json/Makefile \
     compilers/json/Makefile \
     compilers/ncigen/Makefile \
     compilers/nqp/Makefile \
@@ -1413,6 +1414,7 @@
 	$(MAKE) compilers/tge
 	$(MAKE) compilers/nqp
 	$(MAKE) compilers/json
+	$(MAKE) compilers/data_json
 
 compilers-clean :
 	$(MAKE) compilers/pct clean
@@ -1420,6 +1422,7 @@
 	$(MAKE) compilers/tge clean
 	$(MAKE) compilers/nqp clean
 	$(MAKE) compilers/json clean
+	$(MAKE) compilers/data_json clean
 	$(MAKE) compilers/pirc clean
 
 ###############################################################################

Modified: trunk/tools/dev/install_dev_files.pl
==============================================================================
--- trunk/tools/dev/install_dev_files.pl	Mon Sep  7 20:45:05 2009	(r41136)
+++ trunk/tools/dev/install_dev_files.pl	Mon Sep  7 21:07:11 2009	(r41137)
@@ -80,7 +80,7 @@
     srcdir      => '/usr/src/',      # parrot/ subdir added below
     versiondir  => '',
     'dry-run'   => 0,
-    packages    => 'devel|pct|tge|nqp',
+    packages    => 'devel|pct|tge|nqp|data_json',
 );
 
 my @manifests;


More information about the parrot-commits mailing list