Permalink
Browse files

Display current rule

Need CSS though.
  • Loading branch information...
1 parent 9de249b commit 054e158951bd0ecfc63cc26d6ae5d9858780ac39 @cognominal committed Jun 23, 2012
Showing with 18 additions and 13 deletions.
  1. +1 −1 META.info
  2. +2 −0 README.md
  3. 0 bin/jsonParseTree
  4. 0 bin/testJson
  5. +0 −1 i.html
  6. +1 −1 package.json
  7. +14 −10 src/hilite.coffee
View
@@ -1,6 +1,6 @@
{
"name" : "parse-tree-server",
- "version" : "0.0.3",
+ "version" : "0.0.4",
"description" : "parse tree server",
"depends" : ["JSON::Tiny"],
"source-url" : "http://github.com/cognominal/codeview"
View
@@ -21,13 +21,15 @@ Coffeescript is used to convert `.coffee` files in `.js` ones.
* Support many highlighted view ports (use class instead if id to identify relevant HTML elements
* Use express to serve the files (SFW will use express anyway)
* Dynamically generate the parse according to the suffix
+* Support json parse trees for different parse engines
* Split bin/matchToJson into a library and code calling it
* implement a recorder and a demo mode
* maybe create a .dot file to document the information flow
* make it a SFW plugin (the previous steps are preparatory ones)
* create an IRC like plugin in SFW
* Embed rakudo in nodejs.
* tests!! don't know yet how to do browser side tests. Probably stuff based on jsdom.
+* Better doc
Note: to install SFW, I created a gist https://gist.github.com/2887964
View
0 bin/jsonParseTree 100644 → 100755
No changes.
View
0 bin/testJson 100644 → 100755
No changes.
View
1 i.html
@@ -11,7 +11,6 @@
<div id="current-rule"></div>
<div id="parse-crumbs"></div>
<div style="display:none;">breadcrumbs: rule stack from top to reduce current selection</div>
- <div id="rules"></div>
<pre class="code-top"/>
</body>
View
@@ -2,7 +2,7 @@
"name": "parse-tree-server",
"description": "parse tree server",
"keywords": ["web", "server", "syntax", "highlighter"],
- "version": "0.0.3",
+ "version": "0.0.4",
"author": "Stéphane Payrard <cognominal@gmail.com>",
"engines": { "node": ">=0.1.99" },
"bin": { "hilite-server": "./bin/hilite-server" },
View
@@ -7,7 +7,6 @@ $ ->
# we update breadcrumbs on code hovering until we click on the code
$(".code").live('vmouseover',
(ev) ->
- console.log "over"
return unless bread_crumbs_on_hover
ev.stopPropagation()
hilite ev
@@ -66,18 +65,23 @@ $ ->
return ''
+# `hilite` is the entry point for updating the breadcrumbs and rule pane
+
hilite = (ev) ->
elt = ev.currentTarget
mkCrumbs(elt)
- rules = $('#rules')
- if ((rule = ruleNm elt) and (ruleCode = rules.attr(data)[rule]))
- rules.text ruleCode
+ # extract the current rule to add it to the rule vieport
+ ruleElt = $('#current-rule')
+ elt = elt.parentNode
+ if (rule = ruleNm elt) and (rulesStr = ruleElt.attr('data'))
+ ruleElt.text ((JSON.parse rulesStr)[rule])
-# A breadcrumb displays the reduction sequence from the parse top. Making a breadcrumb bar
-# from the rule callstack that reduces the selected text. When a inner reduction
-# element has the same text as the outer, the corresponding parse crumbs are
-# grouped into an td element; that is, they are displayed in a vertical group.
+# A breadcrumb displays the reduction sequence from the parse top. Making a
+# breadcrumb bar from the rule callstack that reduces the selected text. When a
+# inner reduction element has the same text as the outer, the corresponding
+# parse crumbs are grouped into an td element; that is, they are displayed in a
+# vertical group.
mkCrumbs = (elt) ->
$(".code").removeClass "colored"
@@ -125,7 +129,7 @@ $ ->
# console.log "=#{klass}"
e.addClass 'docco-' + d if klass and d = docco[klass];
e.addClass 'rule-' + klass if klass
- e.addClass 'code'
+ e.addClass 'code' # is that necessary except for the englobing element?
e.attr('id', prefix + id++)
return e
@@ -141,7 +145,7 @@ $ ->
generateView = (elt, data, id=0, prefix='') ->
insertParseTree elt, data.parseTree;
- $('#rules').attr('data', data.rules)
+ $('#current-rule').attr('data', JSON.stringify(data.rules))
$.getJSON 'data/parsed.json', (data) ->

0 comments on commit 054e158

Please sign in to comment.