diff parser-demo.js @ 14:95b27aa47788 default tip

parse tree now displays as html.
author Atul Varma <varmaa@toolness.com>
date Sun, 31 May 2009 03:57:37 -0700
parents 1b7ea033b3f6
children
line wrap: on
line diff
--- a/parser-demo.js	Sat May 30 16:55:51 2009 -0700
+++ b/parser-demo.js	Sun May 31 03:57:37 2009 -0700
@@ -28,6 +28,9 @@
 
   new Parsing.Symbol({name: 'number',
                       match: /^[0-9]+/,
+                      toHtml: function() {
+                        return document.createTextNode(this.value);
+                      },
                       nullDenotation: function() {
                         return this;
                       },
@@ -45,6 +48,9 @@
   $('.tokenization').empty();
   $('.parse-tree').empty();
 
+  if (!code)
+    return;
+  
   try {
     var tokens = Parsing.tokenize({lexicon: MyLexicon,
                                    text: code});
@@ -83,7 +89,7 @@
     throw e;
   }
 
-  $('.parse-tree').text(parseTree.toString());
+  $('.parse-tree').append(parseTree.toHtml());
 }
 
 $(window).ready(