[pypy-svn] r38199 - in pypy/dist/pypy/doc: . image

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Feb 8 20:17:12 CET 2007


Author: cfbolz
Date: Thu Feb  8 20:17:07 2007
New Revision: 38199

Added:
   pypy/dist/pypy/doc/image/parsing_example10.dot
Modified:
   pypy/dist/pypy/doc/rlib.txt
Log:
small fixes, addition of a slightly larger example


Added: pypy/dist/pypy/doc/image/parsing_example10.dot
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/doc/image/parsing_example10.dot	Thu Feb  8 20:17:07 2007
@@ -0,0 +1,37 @@
+digraph G{
+"-1220061652" [label="object"];
+"-1220061652" -> "-1220127636";
+"-1220127636" [label="entry"];
+"-1220127636" -> "-1213915636";
+"-1213915636" [shape=box,label="STRING\n'a'"];
+"-1220127636" -> "-1214251156";
+"-1214251156" [shape=box,label="STRING\n'5'"];
+"-1220061652" -> "-1220063188";
+"-1220063188" [label="entry"];
+"-1220063188" -> "-1214253076";
+"-1214253076" [shape=box,label="STRING\n'b'"];
+"-1220063188" -> "-1220059444";
+"-1220059444" [label="array"];
+"-1220059444" -> "-1214253364";
+"-1214253364" [shape=box,label="NUMBER\n'1'"];
+"-1220059444" -> "-1214254292";
+"-1214254292" [shape=box,label="__0_null\n'null'"];
+"-1220059444" -> "-1214253268";
+"-1214253268" [shape=box,label="NUMBER\n'3'"];
+"-1220059444" -> "-1214252596";
+"-1214252596" [shape=box,label="__1_true\n'true'"];
+"-1220059444" -> "-1220062260";
+"-1220062260" [label="object"];
+"-1220062260" -> "-1220060116";
+"-1220060116" [label="entry"];
+"-1220060116" -> "-1214211860";
+"-1214211860" [shape=box,label="STRING\n'f'"];
+"-1220060116" -> "-1214210132";
+"-1214210132" [shape=box,label="STRING\n'g'"];
+"-1220062260" -> "-1220062868";
+"-1220062868" [label="entry"];
+"-1220062868" -> "-1214211956";
+"-1214211956" [shape=box,label="STRING\n'h'"];
+"-1220062868" -> "-1214212308";
+"-1214212308" [shape=box,label="NUMBER\n'6'"];
+}

Modified: pypy/dist/pypy/doc/rlib.txt
==============================================================================
--- pypy/dist/pypy/doc/rlib.txt	(original)
+++ pypy/dist/pypy/doc/rlib.txt	Thu Feb  8 20:17:07 2007
@@ -54,7 +54,7 @@
 
 ``ComputedIntSymbolic``:
     Instances of ``ComputedIntSymbolic`` are treated like integers of unknown
-    value by the annotator. The value is determined by a non-argument function
+    value by the annotator. The value is determined by a no-argument function
     (which needs to be passed into the constructor of the class). When the
     backend emits code, the function is called to determine the value.
 
@@ -93,7 +93,7 @@
     carries exactly one integer field. The class should have ``__slots__``
     with exactly one entry defined. After translation, instances of this class
     won't be allocated but represented by *tagged pointers**, that is pointers
-    who have the lowest bit set.
+    that have the lowest bit set.
 
 .. _objectmodel: ../../pypy/rlib/objectmodel.py
 
@@ -120,7 +120,7 @@
 ``tofloat``. Since RPython does not support operator overloading, all the
 special methods of ``rbigint`` that would normally start and end with "__" have
 these underscores left out for better readability (so ``a.add(b)`` can be used
-to add two rbigint).
+to add two rbigint instances).
 
 .. _rbigint: ../../pypy/rlib/rbigint.py
 
@@ -148,7 +148,7 @@
 ==========
 
 The rstack_ module allows an RPython progam to control its own execution stack.
-This is mostly only useful if the program is translated using stackless. An old
+This is only useful if the program is translated using stackless. An old
 description of the exposed functions is below.
 
 We introduce an RPython type ``frame_stack_top`` and a built-in function
@@ -325,16 +325,15 @@
     IGNORE: " ";
     DECIMAL: "0|[1-9][0-9]*";
     additive: multitive "+" additive |
-              multitive "-" additive |
               multitive;
     multitive: primary "*" multitive |
-               primary "/" multitive |
                primary;
     primary: "(" additive ")" | DECIMAL;
 
-This grammar describes the syntax of arithmetic impressions. The tokenizer
+This grammar describes the syntax of arithmetic impressions involving addition
+and multiplication. The tokenizer
 produces a stream of either DECIMAL tokens or tokens that have matched one of
-the literals "+", "-", "*" or "/". Any space will be ignored. The grammar
+the literals "+", "*", "(" or ")". Any space will be ignored. The grammar
 produces a syntax tree that follows the precedence of the operators. For example
 the expression ``12 + 4 * 5`` is parsed into the following tree:
 
@@ -378,7 +377,7 @@
 contains a lot of nodes that are not really conveying useful information.
 To get rid of some of them, there is some support in the grammar format to
 automatically create a visitor that transforms the tree to remove the additional
-nodes. The simplest such transformation is to just remove nodes, but there are
+nodes. The simplest such transformation just removes nodes, but there are
 more complex ones.
 
 The syntax for these transformations is to enclose symbols in expansions of a
@@ -505,7 +504,28 @@
 Full Example
 ------------
 
-XXX to be written
+A semi-complete parser for the `json format`_::
+
+    STRING: "\\"[^\\\\"]*\\"";
+    NUMBER: "\-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][\+\-]?[0-9]+)?";
+    IGNORE: " |\n";
+    value: <STRING> | <NUMBER> | <object> | <array> | <"null"> |
+           <"true"> | <"false">;
+    object: ["{"] (entry [","])* entry ["}"];
+    array: ["["] (value [","])* value ["]"];
+    entry: STRING [":"] value;
+
+
+The resulting tree for parsing the string::
+
+    {"a": "5", "b": [1, null, 3, true, {"f": "g", "h": 6}]}
+
+looks like this:
+
+.. graphviz:: image/parsing_example10.dot
+
+
 
 .. _`Prolog interpreter`: ../../pypy/lang/prolog/
 .. _parsing: ../../pypy/rlib/parsing/
+.. _`json format`: http://www.json.org



More information about the Pypy-commit mailing list