Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Spec Draft for jptf : json parse tree format

probalby a misnomer because it will evovle in something bigger.
  • Loading branch information...
commit 91f6c9df958238cce13a48593182703e9c4fbacf 1 parent 25ac371
@cognominal authored
Showing with 134 additions and 7 deletions.
  1. +134 −0 specs/json-format.txt
  2. +0 −7 t
View
134 specs/json-format.txt
@@ -0,0 +1,134 @@
+early draft
+
+= json parse tree format and protocol
+
+
+Editor: Stéphane Payrard (cognominal@gmail.com)
+
+== Introduction
+
+This document is in its 0.0.1 version and documents the 1.0.0 version
+of the json parse tree format (jptf).
+
+The jptf is a an information format for exchanges between an
+editing viewport and a grammar engine. The viewport displays code that
+has been parsed by the grammar engine. The information provided by
+the grammar engine allows the viewport to display information about the
+parsed code. At this point the editing view is readonly so the
+transfer of information is just a one time initialization of the view
+port from information generated by the grammar engine. This spec
+will later describe a http based protocol for granular interection
+between the editing viewport and the grammar engine.
+
+=== Sample implementation
+
+This material described in this proposal will be part of a larger
+framework designed for web based lico (literate collaboration). A
+sample implementation uses the lite viewport widget as editing
+viewport and nqp and rakudo as grammar engines.
+
+https://github.com/cognominal/codeview
+
+=== place of jptf in a larger scheme
+
+The statements in this section are my opinions and are not related to
+the jptf proposal as a specification. The motivation of these opinions
+should be the objet of other documents. They should even be placed in
+the context of Ars Industrialis manifesto to make total sense. Agile
+development purpose should not be only the acceleration of inner loops
+but thinking the meaning and the purpose of outer loops. It should
+empower the citizen, not feed the Bernaysian cancer like most web
+initiatives, startup and attention grabbing companies like facebook.
+
+This choices of the web implementing the lite viewport and nqp and
+rakudo as grammar engine are not incidental.
+
+A lico environment (licor) has no chance of wide adoption in a wide
+platform range if it not based on a modern version of the web that I
+will abusively call html5. The modern web (as per 2012) includes many
+technologies related but different from html5 per se. A collaborative
+environment cannot be deemed literate if it does not include a widget
+with capabilities similar to the lite view port. A licor must stand on
+a very powerful flexible language wich people can evolve into
+slangs. Slangs is Perl 6 turbo boosted idea of DSLs. Perl 6 rakudo
+implementation must eventually be ported to v8 and made interoperable
+with nodejs. For Perl 6 libraries to be in the spirit of nodejs, a
+certification label must be designed that a Perl 6 library is fully
+asynchroneous.
+
+A complex language like Perl 6 has no chance of taking off if he is
+not part of a comprensive "mothering environment" like one got when
+learning its maternal language. Also, such a environment will still be
+useful with computer languages not designed with a linguistic mind
+frame.
+
+The point of this document is to give enough information to implement
+other interoperable viewports and grammar engines.
+
+== glossary
+
+TBD
+
+ast:
+brew:
+dsl:
+grammar engine:
+jpt:
+jptf:
+licor: literate collaborative environement
+lite: literate editor, the core widget of the zbrew licor
+nqp: a simplified implementation of perl 6 necessary to bootstrap rakudo.
+parse tree:
+perl 6: A language with a very good grammar language. A complete redesign of the Perl language not retrocompativle with previous verions. See perl6.org
+rakudo: An Perl 6 implementation
+literate viewport: in a lico, the main focus of interaction to edit code
+zbrew: a tool that should evolve into a licor
+
+== Description of the component of a string in jptf
+
+This jptf document describes the key and values of the jptf
+subobjets. Any implementor is free to add unspecified pairs for their
+own purpose but they must start with an underscore character to avoid
+collision with future keys.
+
+A lite viewport is driven by a json file which contains all the
+information to generate a lite viewport DOM. This information is
+mostly a parse tree and the grammar used to generate it. We call this
+format, the json parse tree format (jptf). The jptf version
+documented here is 1.0.0. We use semantic versionning. A string in
+this format is called a jpt.
+
+The keys of the top most object are "version", "rules", "parseTree", "docco".
+"version" associated value is the format version, wich is currently, as we said, 1.0.0.
+
+"grammar" associated value is an objet that represents the grammar;
+the value associated to a rule name is its code. This code can be its
+source code string or its jpt.
+
+"docco" associated value is an object that associates some rule names
+with docco names so that the lite viewport can use CSS to statically
+hilite tokens according to their type. Note that a token is not
+necessarily a substring associated to a leaf of the parse tree.
+Indeed in a Perl 6 grammar, the tokenisation step is defined as part
+of the grammar, as a result a token is usually a composite match.
+A mjr is either a string or a match object. A match object
+associates a rule name with an array of mjrs. If the array is
+constituted of a unique mjr, it can be replaced by the object itself
+(not yet supported by the lite view port.
+
+"parseTree" associated value is the match json representation (mjr).
+
+"doccoCommentRuleName" associated value is the rule name for which the
+resulting reduction will be display
+
+
+Example of string conformant with jptf :
+
+ {"rules":{ "TOP" : "token TOP { <paren> || <addTerm> }\n ", "paren" : "token paren { '(' <TOP> ')' }\n ", "mulTerm" : "token mulTerm { <atom> '*' <atom> | <paren> | <atom> }\n ", "addTerm" : "token addTerm { <mulTerm> '+' <mulTerm> | <paren> | <atom> }\n ", "atom" : "token atom { <int> || <id> }\n ", "int" : "token int { \\d+ }\n ", "id" : "token id { \\w+ }\n}", "infix" : "token infix:sym<*> { <sym> <O('%mulitplicative')> }\n\n\n" }, "parseTree":{"TOP":[{"paren":["(",{"TOP":[{"addTerm":[{"atom":[{"id":["a"]}]}]}]},")"]}]}, "docco":{ "TOP" : "TOP", "string" : "s", "number" : "m" }}
+
+About docco : http://jashkenas.github.com/docco/
+About json : http://www.json.org/
+
+
+
+
View
7 t
@@ -1,7 +0,0 @@
-grammar G {
- token mul { <term> '*' <term> }
- token add { <term> '+' <term> }
- token term { <int> || <id> }
- token int { \d+ }
- toekn id { \w+ }
-}

0 comments on commit 91f6c9d

Please sign in to comment.
Something went wrong with that request. Please try again.