summaryrefslogtreecommitdiff
path: root/src/www/syntax-editor/ast.js
diff options
context:
space:
mode:
authorjohn.j.camilleri <john.j.camilleri@chalmers.se>2013-01-11 15:33:17 +0000
committerjohn.j.camilleri <john.j.camilleri@chalmers.se>2013-01-11 15:33:17 +0000
commitb8e3fe7bc099d3ee09f1c5dfe05fab1fd73afed1 (patch)
treebdea3f8224ba39bd85f6ca4c1f849113765393ef /src/www/syntax-editor/ast.js
parentbe5a313372fbafa13f8f45357b9ee3a84d18b10f (diff)
Syntax editor: initial support for string literals
Also a bug fix when switching to editor, although this still messes up when using the letters grammar. Also updated readme with options, and some style improvements.
Diffstat (limited to 'src/www/syntax-editor/ast.js')
-rw-r--r--src/www/syntax-editor/ast.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/www/syntax-editor/ast.js b/src/www/syntax-editor/ast.js
index 50c417e96..698272228 100644
--- a/src/www/syntax-editor/ast.js
+++ b/src/www/syntax-editor/ast.js
@@ -73,6 +73,7 @@ function AST(fun, cat) {
return new ASTNode({
"fun": fun,
"cat": cat,
+ "string": "", // for String literals
"deps": {}, // dependent types
"children": []
});
@@ -304,7 +305,10 @@ function AST(fun, cat) {
this.toString = function() {
var s = "";
function visit(node) {
- s += node.fun ? node.fun : "?" ;
+ if (node.cat == "String")
+ s += '"' + ((node.string) ? node.string : "") + '"';
+ else
+ s += node.fun ? node.fun : "?" ;
if (!node.hasChildren())
// if (node.children.length == 0)
return;