diff options
| author | john.j.camilleri <john.j.camilleri@chalmers.se> | 2012-11-21 15:24:44 +0000 |
|---|---|---|
| committer | john.j.camilleri <john.j.camilleri@chalmers.se> | 2012-11-21 15:24:44 +0000 |
| commit | 381dc3900cbdef699ace67113c61adf2016eef17 (patch) | |
| tree | 7a23fbcec8d19e462e619afb14bcabc4f5f2717a /src/www/syntax-editor/editor.js | |
| parent | 8bd58a02970d3650b5b3efb6298f40529737c2d8 (diff) | |
Syntax editor: start with initial AST
Note that the argument has been renamed to initial.abstr
(Where abstr means an abstract syntax tree in string form, NOT an AST object)
Diffstat (limited to 'src/www/syntax-editor/editor.js')
| -rw-r--r-- | src/www/syntax-editor/editor.js | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/www/syntax-editor/editor.js b/src/www/syntax-editor/editor.js index 9fa7ad737..df2a49da8 100644 --- a/src/www/syntax-editor/editor.js +++ b/src/www/syntax-editor/editor.js @@ -7,6 +7,22 @@ // } /* --- Main Editor object --------------------------------------------------- */ +/* When creating the object, stuff gets called in this order: +new EditorMenu + server.get_grammarlists + EditorMenu.show_grammarlist + EditorMenu.change_grammar + server.switch_to_other_grammar + server.get_grammar_info + EditorMenu.update_startcat_menu + EditorMenu.update_language_menu + Editor.change_grammar + Editor.get_grammar_constructors + Editor.start_fresh + Editor.update_current_node(); + Editor.redraw_tree(); + Editor.get_refinements(); +*/ function Editor(server,opts) { var t = this; /* --- Configuration ---------------------------------------------------- */ @@ -18,7 +34,7 @@ function Editor(server,opts) { grammar: null, startcat: null, languages: null, - ast: null, + abstr: null, node_id: null }, show: { @@ -98,19 +114,20 @@ Editor.prototype.change_grammar=function(grammar_info) { } Editor.prototype.change_startcat=function(startcat) { - this.startcat = startcat; - this.start_fresh(); + var t = this; + t.startcat = startcat; + t.start_fresh(); } // Called after changing grammar or startcat Editor.prototype.start_fresh=function () { - with(this) { - ast = new AST(null, get_startcat()); - redraw_tree(); - update_current_node(); - get_refinements(); - clear(ui.lin); + var t = this; + t.ast = new AST(null, t.get_startcat()); + if (t.options.initial.abstr) { + t.import_ast(t.options.initial.abstr); } + t.update_current_node(); + clear(t.ui.lin); } /* --- Functions for handling tree manipulation ----------------------------- */ |
