From eb013c0b06481050d3a209b7763ced8be9787e76 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Thu, 29 Aug 2013 20:36:06 +0000 Subject: [PATCH] almost functional version of the javascript runtime --- src/runtime/javascript/editor.html | 2 +- src/runtime/javascript/editorGrammar.js | 2 +- src/runtime/javascript/gfjseditor.js | 17 +- src/runtime/javascript/gflib.js | 471 ++++++++++++------------ src/runtime/javascript/grammar.js | 2 +- 5 files changed, 250 insertions(+), 244 deletions(-) diff --git a/src/runtime/javascript/editor.html b/src/runtime/javascript/editor.html index ecbb62419..ccf23616b 100644 --- a/src/runtime/javascript/editor.html +++ b/src/runtime/javascript/editor.html @@ -10,7 +10,7 @@ Web-based Syntax Editor - +
diff --git a/src/runtime/javascript/editorGrammar.js b/src/runtime/javascript/editorGrammar.js index 93b59572b..1fa1fe639 100644 --- a/src/runtime/javascript/editorGrammar.js +++ b/src/runtime/javascript/editorGrammar.js @@ -1 +1 @@ -var Editor = new GFGrammar(new GFAbstract("S",{Available: new Type([], "Adjective"), Bulgarian: new Type([], "Noun"), Command: new Type(["Verb", "Determiner", "Noun"], "Sentence"), CommandAdj: new Type(["Verb", "Determiner", "Adjective", "Noun"], "Sentence"), Copy: new Type([], "Verb"), Cut: new Type([], "Verb"), Danish: new Type([], "Noun"), DefPlDet: new Type([], "Determiner"), DefSgDet: new Type([], "Determiner"), Delete: new Type([], "Verb"), English: new Type([], "Noun"), Enter: new Type([], "Verb"), ErrorMessage: new Type(["Adjective", "Noun"], "Sentence"), Finnish: new Type([], "Noun"), Float_N: new Type([], "Noun"), French: new Type([], "Noun"), German: new Type([], "Noun"), IndefPlDet: new Type([], "Determiner"), IndefSgDet: new Type([], "Determiner"), Integer_N: new Type([], "Noun"), Italian: new Type([], "Noun"), Label: new Type(["Noun"], "Sentence"), Language: new Type([], "Noun"), Next: new Type([], "Adjective"), Node: new Type([], "Noun"), Norwegian: new Type([], "Noun"), Page: new Type([], "Noun"), Parse: new Type([], "Verb"), Paste: new Type([], "Verb"), Previous: new Type([], "Adjective"), RandomlyCommand: new Type(["Verb", "Determiner", "Noun"], "Sentence"), Redo: new Type([], "Verb"), Refine: new Type([], "Verb"), Refinement: new Type([], "Noun"), Replace: new Type([], "Verb"), Russian: new Type([], "Noun"), Select: new Type([], "Verb"), Show: new Type([], "Verb"), SingleWordCommand: new Type(["Verb"], "Sentence"), Spanish: new Type([], "Noun"), String_N: new Type([], "Noun"), Swedish: new Type([], "Noun"), Tree: new Type([], "Noun"), Undo: new Type([], "Verb"), Wrap: new Type([], "Verb"), Wrapper: new Type([], "Noun")}),{EditorEng: new GFConcrete({},{Available: function(cs){return new Arr(new Arr(new Str("available"), new Str("available"), new Str("available's"), Editor.concretes["EditorEng"].rule("_0", cs), Editor.concretes["EditorEng"].rule("_0", cs), new Seq(new Str("more"), new Str("available's")), Editor.concretes["EditorEng"].rule("_2", cs), Editor.concretes["EditorEng"].rule("_2", cs), new Seq(new Str("most"), new Str("available's")), new Str("availablely")));}, Bulgarian: function(cs){return new Arr(new Arr(new Suffix("Bulgarian", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Bulgarians", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Command: function(cs){return new Arr(new Seq(Editor.concretes["EditorEng"].rule("_13", cs), Editor.concretes["EditorEng"].rule("_14", cs), Editor.concretes["EditorEng"].rule("_18", cs), Editor.concretes["EditorEng"].rule("_22", cs)));}, CommandAdj: function(cs){return new Arr(new Seq(Editor.concretes["EditorEng"].rule("_13", cs), Editor.concretes["EditorEng"].rule("_14", cs),(new Arr(new Seq((new Arr(Editor.concretes["EditorEng"].rule("_25", cs), Editor.concretes["EditorEng"].rule("_25", cs), Editor.concretes["EditorEng"].rule("_25", cs), Editor.concretes["EditorEng"].rule("_25", cs), Editor.concretes["EditorEng"].rule("_25", cs), Editor.concretes["EditorEng"].rule("_25", cs), Editor.concretes["EditorEng"].rule("_25", cs), Editor.concretes["EditorEng"].rule("_25", cs))).sel((new Arr(new Int(4), new Int(5), new Int(6))).sel(cs[3].sel(new Int(1)))), Editor.concretes["EditorEng"].rule("_31", cs).sel(new Int(0)).sel(new Int(1))), new Seq(Editor.concretes["EditorEng"].rule("_25", cs), Editor.concretes["EditorEng"].rule("_31", cs).sel(new Int(1)).sel(new Int(1))))).sel(Editor.concretes["EditorEng"].rule("_16", cs)), Editor.concretes["EditorEng"].rule("_22", cs)));}, Copy: function(cs){return new Arr(new Suffix("cop", new Arr(new Str("y"), new Str("ies"), new Str("ied"), new Str("ying"), new Str("ied"))), new Int(1));}, Cut: function(cs){return new Arr(new Suffix("cut", new Arr(new Str(""), new Str("s"), new Str("ted"), new Str("ting"), new Str("ted"))), new Int(1));}, Danish: function(cs){return new Arr(new Arr(new Suffix("Danish", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Danishes", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, DefPlDet: function(cs){return new Arr(new Str("the"), new Int(1), new Suffix("the", new Arr(new Str("y"), new Str("m"), new Str("irs"))));}, DefSgDet: function(cs){return new Arr(new Str("the"), new Int(0), new Suffix("it", new Arr(new Str(""), new Str(""), new Str("s"))));}, Delete: function(cs){return new Arr(new Suffix("delet", Editor.concretes["EditorEng"].rule("_58", cs)), new Int(1));}, English: function(cs){return new Arr(new Arr(new Suffix("English", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Englishes", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Enter: function(cs){return new Arr(new Suffix("enter", new Arr(new Str(""), new Str("s"), new Str("red"), new Str("ring"), new Str("red"))), new Int(1));}, ErrorMessage: function(cs){return new Arr(new Seq(new Str("no"), Editor.concretes["EditorEng"].rule("_13", cs), Editor.concretes["EditorEng"].rule("_14", cs).sel(new Int(1)).sel(new Int(0))));}, Finnish: function(cs){return new Arr(new Arr(new Suffix("Finnish", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Finnishes", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Float_N: function(cs){return new Arr(new Arr(new Suffix("float", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("floats", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, French: function(cs){return new Arr(new Arr(new Suffix("French", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Frenches", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, German: function(cs){return new Arr(new Arr(new Suffix("German", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Germans", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, IndefPlDet: function(cs){return new Arr(Editor.concretes["EditorEng"].rule("_19", cs), new Int(1), new Suffix("ones", Editor.concretes["EditorEng"].rule("_8", cs)));}, IndefSgDet: function(cs){return new Arr(new Str("a"), new Int(0), new Suffix("one", Editor.concretes["EditorEng"].rule("_6", cs)));}, Integer_N: function(cs){return new Arr(new Arr(new Suffix("integer", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("integers", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Italian: function(cs){return new Arr(new Arr(new Suffix("Italian", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Italians", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Label: function(cs){return new Arr(Editor.concretes["EditorEng"].rule("_13", cs).sel(new Int(0)));}, Language: function(cs){return new Arr(new Arr(new Suffix("language", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("languages", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Next: function(cs){return new Arr(new Suffix("next", new Arr(new Str(""), new Str(""), new Str("'s"), new Str("er"), new Str("er"), new Str("er's"), new Str("est"), new Str("est"), new Str("est's"), new Str("ly"))));}, Node: function(cs){return new Arr(new Arr(new Suffix("node", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("nodes", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Norwegian: function(cs){return new Arr(new Arr(new Suffix("Norwegian", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Norwegians", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Page: function(cs){return new Arr(new Arr(new Suffix("page", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("pages", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Parse: function(cs){return new Arr(new Suffix("pars", Editor.concretes["EditorEng"].rule("_58", cs)), new Int(1));}, Paste: function(cs){return new Arr(new Suffix("past", Editor.concretes["EditorEng"].rule("_58", cs)), new Int(1));}, Previous: function(cs){return new Arr(new Arr(new Str("previous"), new Str("previous"), new Str("previous'"), Editor.concretes["EditorEng"].rule("_125", cs), Editor.concretes["EditorEng"].rule("_125", cs), new Seq(new Str("more"), new Str("previous'")), Editor.concretes["EditorEng"].rule("_127", cs), Editor.concretes["EditorEng"].rule("_127", cs), new Seq(new Str("most"), new Str("previous'")), new Str("previously")));}, RandomlyCommand: function(cs){return new Arr(new Seq(Editor.concretes["EditorEng"].rule("_13", cs), Editor.concretes["EditorEng"].rule("_14", cs), Editor.concretes["EditorEng"].rule("_18", cs), Editor.concretes["EditorEng"].rule("_22", cs), new Str("at"), new Str("random")));}, Redo: function(cs){return new Arr(new Suffix("redo", Editor.concretes["EditorEng"].rule("_133", cs)), new Int(1));}, Refine: function(cs){return new Arr(new Suffix("refin", Editor.concretes["EditorEng"].rule("_58", cs)), new Int(1));}, Refinement: function(cs){return new Arr(new Arr(new Suffix("refinement", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("refinements", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Replace: function(cs){return new Arr(new Suffix("replac", Editor.concretes["EditorEng"].rule("_58", cs)), new Int(1));}, Russian: function(cs){return new Arr(new Arr(new Suffix("Russian", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Russians", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Select: function(cs){return new Arr(new Suffix("select", Editor.concretes["EditorEng"].rule("_148", cs)), new Int(1));}, Show: function(cs){return new Arr(new Suffix("show", Editor.concretes["EditorEng"].rule("_148", cs)), new Int(1));}, SingleWordCommand: function(cs){return new Arr(new Seq(Editor.concretes["EditorEng"].rule("_13", cs), Editor.concretes["EditorEng"].rule("_22", cs)));}, Spanish: function(cs){return new Arr(new Arr(new Suffix("Spanish", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Spanishes", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, String_N: function(cs){return new Arr(new Arr(new Suffix("string", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("strings", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Swedish: function(cs){return new Arr(new Arr(new Suffix("Swedish", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("Swedishes", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Tree: function(cs){return new Arr(new Arr(new Suffix("tree", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("trees", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, Undo: function(cs){return new Arr(new Suffix("undo", Editor.concretes["EditorEng"].rule("_133", cs)), new Int(1));}, Wrap: function(cs){return new Arr(new Suffix("wrap", new Arr(new Str(""), new Str("s"), new Str("ped"), new Str("ping"), new Str("ped"))), new Int(1));}, Wrapper: function(cs){return new Arr(new Arr(new Suffix("wrapper", Editor.concretes["EditorEng"].rule("_6", cs)), new Suffix("wrappers", Editor.concretes["EditorEng"].rule("_8", cs))), new Int(0));}, _0: function(cs){return new Seq(new Str("more"), new Str("available"));}, _12: function(cs){return cs[0].sel(new Int(0));}, _125: function(cs){return new Seq(new Str("more"), new Str("previous"));}, _127: function(cs){return new Seq(new Str("most"), new Str("previous"));}, _13: function(cs){return Editor.concretes["EditorEng"].rule("_12", cs).sel(new Int(0));}, _133: function(cs){return new Arr(new Str(""), new Str("es"), new Str("ed"), new Str("ing"), new Str("ed"));}, _14: function(cs){return cs[1].sel(new Int(0));}, _148: function(cs){return new Arr(new Str(""), new Str("s"), new Str("ed"), new Str("ing"), new Str("ed"));}, _15: function(cs){return cs[2].sel(new Int(0));}, _16: function(cs){return cs[1].sel(new Int(1));}, _17: function(cs){return Editor.concretes["EditorEng"].rule("_15", cs).sel(Editor.concretes["EditorEng"].rule("_16", cs));}, _18: function(cs){return Editor.concretes["EditorEng"].rule("_17", cs).sel(new Int(1));}, _182: function(cs){return new Arr(cs[0], cs[0], cs[0]);}, _19: function(cs){return new Seq();}, _2: function(cs){return new Seq(new Str("most"), new Str("available"));}, _20: function(cs){return new Arr(new Str("yourself"), Editor.concretes["EditorEng"].rule("_19", cs));}, _21: function(cs){return cs[0].sel(new Int(1));}, _22: function(cs){return Editor.concretes["EditorEng"].rule("_20", cs).sel(Editor.concretes["EditorEng"].rule("_21", cs));}, _25: function(cs){return Editor.concretes["EditorEng"].rule("_15", cs).sel(new Int(0));}, _31: function(cs){return cs[3].sel(new Int(0));}, _58: function(cs){return new Arr(new Str("e"), new Str("es"), new Str("ed"), new Str("ing"), new Str("ed"));}, _6: function(cs){return new Arr(new Str(""), new Str(""), new Str("'s"));}, _8: function(cs){return new Arr(new Str(""), new Str(""), new Str("'"));}, Adjective: function(cs){return new Arr(new Arr(cs[0], cs[0], cs[0], cs[0], cs[0], cs[0], cs[0], cs[0], cs[0], cs[0]));}, Determiner: function(cs){return new Arr(cs[0], new Int(0), Editor.concretes["EditorEng"].rule("_182", cs));}, Noun: function(cs){return new Arr(new Arr(Editor.concretes["EditorEng"].rule("_182", cs), Editor.concretes["EditorEng"].rule("_182", cs)), new Int(0));}, Sentence: function(cs){return new Arr(cs[0]);}, Verb: function(cs){return new Arr(new Arr(cs[0], cs[0], cs[0], cs[0], cs[0]), new Int(0));}, "Int": function(cs){return new Arr(cs[0]);}, "Float": function(cs){return new Arr(cs[0]);}, "String": function(cs){return new Arr(cs[0]);}}, new Parser({0:[new Rule(0,[]), new Rule(29,[]), new Rule(35,[])], 1:[new Rule(14,[]), new Rule(24,[])], 2:[new Rule(13,[]), new Rule(23,[])], 3:[new Rule(1,[]), new Rule(12,[]), new Rule(16,[]), new Rule(19,[]), new Rule(20,[]), new Rule(21,[]), new Rule(22,[]), new Rule(25,[]), new Rule(26,[]), new Rule(28,[]), new Rule(30,[]), new Rule(31,[]), new Rule(32,[]), new Rule(42,[]), new Rule(44,[]), new Rule(49,[]), new Rule(50,[]), new Rule(51,[]), new Rule(52,[]), new Rule(55,[])], 6:[new Rule(2,[7, 1, 10]), new Rule(3,[8, 1, 10]), new Rule(4,[7, 2, 10]), new Rule(5,[8, 2, 10]), new Rule(6,[7, 1, 0, 10]), new Rule(7,[8, 1, 0, 10]), new Rule(8,[7, 2, 0, 10]), new Rule(9,[8, 2, 0, 10]), new Rule(18,[0, 10]), new Rule(27,[10]), new Rule(36,[7, 1, 10]), new Rule(37,[8, 1, 10]), new Rule(38,[7, 2, 10]), new Rule(39,[8, 2, 10]), new Rule(47,[7]), new Rule(48,[8])], 8:[new Rule(10,[]), new Rule(11,[]), new Rule(15,[]), new Rule(17,[]), new Rule(33,[]), new Rule(34,[]), new Rule(40,[]), new Rule(41,[]), new Rule(43,[]), new Rule(45,[]), new Rule(46,[]), new Rule(53,[]), new Rule(54,[])], 10:[new Coerce(3), new Coerce(4), new Coerce(5)]},[new FFun("Available",[6, 5, 4, 4, 3, 2, 2, 1, 0, 0]), new FFun("Bulgarian",[10, 9, 9, 8, 7, 7]), new FFun("Command",[11]), new FFun("Command",[12]), new FFun("Command",[13]), new FFun("Command",[14]), new FFun("CommandAdj",[15]), new FFun("CommandAdj",[16]), new FFun("CommandAdj",[17]), new FFun("CommandAdj",[18]), new FFun("Copy",[21, 22, 21, 20, 19]), new FFun("Cut",[25, 26, 25, 24, 23]), new FFun("Danish",[30, 29, 29, 28, 27, 27]), new FFun("DefPlDet",[34, 33, 32, 31]), new FFun("DefSgDet",[36, 35, 35, 31]), new FFun("Delete",[39, 40, 39, 38, 37]), new FFun("English",[44, 43, 43, 42, 41, 41]), new FFun("Enter",[47, 48, 47, 46, 45]), new FFun("ErrorMessage",[49]), new FFun("Finnish",[53, 52, 52, 51, 50, 50]), new FFun("Float_N",[57, 56, 56, 55, 54, 54]), new FFun("French",[61, 60, 60, 59, 58, 58]), new FFun("German",[65, 64, 64, 63, 62, 62]), new FFun("IndefPlDet",[68, 67, 67, 66]), new FFun("IndefSgDet",[71, 70, 70, 69]), new FFun("Integer_N",[75, 74, 74, 73, 72, 72]), new FFun("Italian",[79, 78, 78, 77, 76, 76]), new FFun("Label",[80]), new FFun("Language",[84, 83, 83, 82, 81, 81]), new FFun("Next",[91, 90, 89, 89, 88, 87, 87, 86, 85, 85]), new FFun("Node",[95, 94, 94, 93, 92, 92]), new FFun("Norwegian",[99, 98, 98, 97, 96, 96]), new FFun("Page",[103, 102, 102, 101, 100, 100]), new FFun("Parse",[106, 107, 106, 105, 104]), new FFun("Paste",[110, 111, 110, 109, 108]), new FFun("Previous",[118, 117, 116, 116, 115, 114, 114, 113, 112, 112]), new FFun("RandomlyCommand",[119]), new FFun("RandomlyCommand",[120]), new FFun("RandomlyCommand",[121]), new FFun("RandomlyCommand",[122]), new FFun("Redo",[125, 126, 125, 124, 123]), new FFun("Refine",[129, 130, 129, 128, 127]), new FFun("Refinement",[134, 133, 133, 132, 131, 131]), new FFun("Replace",[137, 138, 137, 136, 135]), new FFun("Russian",[142, 141, 141, 140, 139, 139]), new FFun("Select",[145, 146, 145, 144, 143]), new FFun("Show",[149, 150, 149, 148, 147]), new FFun("SingleWordCommand",[151]), new FFun("SingleWordCommand",[152]), new FFun("Spanish",[156, 155, 155, 154, 153, 153]), new FFun("String_N",[160, 159, 159, 158, 157, 157]), new FFun("Swedish",[164, 163, 163, 162, 161, 161]), new FFun("Tree",[168, 167, 167, 166, 165, 165]), new FFun("Undo",[171, 172, 171, 170, 169]), new FFun("Wrap",[175, 176, 175, 174, 173]), new FFun("Wrapper",[180, 179, 179, 178, 177, 177])],[[new KS("available")],[new KS("available's")],[new KS("more", "available")],[new KS("more", "available's")],[new KS("most", "available")],[new KS("most", "available's")],[new KS("availablely")],[new KS("Bulgarian")],[new KS("Bulgarian's")],[new KS("Bulgarians")],[new KS("Bulgarians'")],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 4), new KS("yourself")],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 4)],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 1), new KS("yourself")],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 1)],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 9), new Arg(3, 4), new KS("yourself")],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 9), new Arg(3, 4)],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 9), new Arg(3, 1), new KS("yourself")],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 9), new Arg(3, 1)],[new KS("copy")],[new KS("copies")],[new KS("copied")],[new KS("copying")],[new KS("cut")],[new KS("cuts")],[new KS("cutted")],[new KS("cutting")],[new KS("Danish")],[new KS("Danish's")],[new KS("Danishes")],[new KS("Danishes'")],[new KS("the")],[new KS("they")],[new KS("them")],[new KS("theirs")],[new KS("it")],[new KS("its")],[new KS("delete")],[new KS("deletes")],[new KS("deleted")],[new KS("deleting")],[new KS("English")],[new KS("English's")],[new KS("Englishes")],[new KS("Englishes'")],[new KS("enter")],[new KS("enters")],[new KS("enterred")],[new KS("enterring")],[new KS("no"), new Arg(0, 9), new Arg(1, 2)],[new KS("Finnish")],[new KS("Finnish's")],[new KS("Finnishes")],[new KS("Finnishes'")],[new KS("float")],[new KS("float's")],[new KS("floats")],[new KS("floats'")],[new KS("French")],[new KS("French's")],[new KS("Frenches")],[new KS("Frenches'")],[new KS("German")],[new KS("German's")],[new KS("Germans")],[new KS("Germans'")],[],[new KS("ones")],[new KS("ones'")],[new KP(["a"],[new Alt(["a"],["eu", "Eu", "uni", "up"]), new Alt(["an"],["un"]), new Alt(["an"],["a", "e", "i", "o", "A", "E", "I", "O"])])],[new KS("one")],[new KS("one's")],[new KS("integer")],[new KS("integer's")],[new KS("integers")],[new KS("integers'")],[new KS("Italian")],[new KS("Italian's")],[new KS("Italians")],[new KS("Italians'")],[new Arg(0, 5)],[new KS("language")],[new KS("language's")],[new KS("languages")],[new KS("languages'")],[new KS("next")],[new KS("next's")],[new KS("nexter")],[new KS("nexter's")],[new KS("nextest")],[new KS("nextest's")],[new KS("nextly")],[new KS("node")],[new KS("node's")],[new KS("nodes")],[new KS("nodes'")],[new KS("Norwegian")],[new KS("Norwegian's")],[new KS("Norwegians")],[new KS("Norwegians'")],[new KS("page")],[new KS("page's")],[new KS("pages")],[new KS("pages'")],[new KS("parse")],[new KS("parses")],[new KS("parsed")],[new KS("parsing")],[new KS("paste")],[new KS("pastes")],[new KS("pasted")],[new KS("pasting")],[new KS("previous")],[new KS("previous'")],[new KS("more", "previous")],[new KS("more", "previous'")],[new KS("most", "previous")],[new KS("most", "previous'")],[new KS("previously")],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 4), new KS("yourself", "at", "random")],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 4), new KS("at", "random")],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 1), new KS("yourself", "at", "random")],[new Arg(0, 4), new Arg(1, 3), new Arg(2, 1), new KS("at", "random")],[new KS("redo")],[new KS("redoes")],[new KS("redoed")],[new KS("redoing")],[new KS("refine")],[new KS("refines")],[new KS("refined")],[new KS("refining")],[new KS("refinement")],[new KS("refinement's")],[new KS("refinements")],[new KS("refinements'")],[new KS("replace")],[new KS("replaces")],[new KS("replaced")],[new KS("replacing")],[new KS("Russian")],[new KS("Russian's")],[new KS("Russians")],[new KS("Russians'")],[new KS("select")],[new KS("selects")],[new KS("selected")],[new KS("selecting")],[new KS("show")],[new KS("shows")],[new KS("showed")],[new KS("showing")],[new Arg(0, 4), new KS("yourself")],[new Arg(0, 4)],[new KS("Spanish")],[new KS("Spanish's")],[new KS("Spanishes")],[new KS("Spanishes'")],[new KS("string")],[new KS("string's")],[new KS("strings")],[new KS("strings'")],[new KS("Swedish")],[new KS("Swedish's")],[new KS("Swedishes")],[new KS("Swedishes'")],[new KS("tree")],[new KS("tree's")],[new KS("trees")],[new KS("trees'")],[new KS("undo")],[new KS("undoes")],[new KS("undoed")],[new KS("undoing")],[new KS("wrap")],[new KS("wraps")],[new KS("wrapped")],[new KS("wrapping")],[new KS("wrapper")],[new KS("wrapper's")],[new KS("wrappers")],[new KS("wrappers'")]],{Adjective:{s: 0, e: 0}, Determiner:{s: 1, e: 2}, Float:{s: -3, e: -3}, Int:{s: -2, e: -2}, Noun:{s: 3, e: 5}, Sentence:{s: 6, e: 6}, String:{s: -1, e: -1}, Verb:{s: 7, e: 8}, __gfVar:{s: -4, e: -4}}, 11))}); +var Editor = new GFGrammar(new GFAbstract("S",{Available: new Type([], "Adjective"), Bulgarian: new Type([], "Noun"), Command: new Type(["Verb", "Determiner", "Noun"], "Sentence"), CommandAdj: new Type(["Verb", "Determiner", "Adjective", "Noun"], "Sentence"), Copy: new Type([], "Verb"), Cut: new Type([], "Verb"), Danish: new Type([], "Noun"), DefPlDet: new Type([], "Determiner"), DefSgDet: new Type([], "Determiner"), Delete: new Type([], "Verb"), English: new Type([], "Noun"), Enter: new Type([], "Verb"), ErrorMessage: new Type(["Adjective", "Noun"], "Sentence"), Finnish: new Type([], "Noun"), Float_N: new Type([], "Noun"), French: new Type([], "Noun"), German: new Type([], "Noun"), IndefPlDet: new Type([], "Determiner"), IndefSgDet: new Type([], "Determiner"), Integer_N: new Type([], "Noun"), Italian: new Type([], "Noun"), Label: new Type(["Noun"], "Sentence"), Language: new Type([], "Noun"), Next: new Type([], "Adjective"), Node: new Type([], "Noun"), Norwegian: new Type([], "Noun"), Page: new Type([], "Noun"), Parse: new Type([], "Verb"), Paste: new Type([], "Verb"), Previous: new Type([], "Adjective"), RandomlyCommand: new Type(["Verb", "Determiner", "Noun"], "Sentence"), Redo: new Type([], "Verb"), Refine: new Type([], "Verb"), Refinement: new Type([], "Noun"), Replace: new Type([], "Verb"), Russian: new Type([], "Noun"), Select: new Type([], "Verb"), Show: new Type([], "Verb"), SingleWordCommand: new Type(["Verb"], "Sentence"), Spanish: new Type([], "Noun"), String_N: new Type([], "Noun"), Swedish: new Type([], "Noun"), Tree: new Type([], "Noun"), Undo: new Type([], "Verb"), Wrap: new Type([], "Verb"), Wrapper: new Type([], "Noun")}),{EditorEng: new GFConcrete({},{0:[new Apply(5,[]), new Apply(34,[]), new Apply(40,[])], 2:[new Apply(19,[]), new Apply(29,[])], 4:[new Apply(18,[]), new Apply(28,[])], 5:[new Apply(6,[]), new Apply(17,[]), new Apply(21,[]), new Apply(24,[]), new Apply(25,[]), new Apply(26,[]), new Apply(27,[]), new Apply(30,[]), new Apply(31,[]), new Apply(33,[]), new Apply(35,[]), new Apply(36,[]), new Apply(37,[]), new Apply(47,[]), new Apply(49,[]), new Apply(54,[]), new Apply(55,[]), new Apply(56,[]), new Apply(57,[]), new Apply(60,[])], 8:[new Apply(7,[new PArg(9), new PArg(12), new PArg(13)]), new Apply(8,[new PArg(10), new PArg(12), new PArg(13)]), new Apply(9,[new PArg(9), new PArg(14), new PArg(13)]), new Apply(10,[new PArg(10), new PArg(14), new PArg(13)]), new Apply(11,[new PArg(9), new PArg(12), new PArg(0), new PArg(13)]), new Apply(12,[new PArg(10), new PArg(12), new PArg(0), new PArg(13)]), new Apply(13,[new PArg(9), new PArg(14), new PArg(0), new PArg(13)]), new Apply(14,[new PArg(10), new PArg(14), new PArg(0), new PArg(13)]), new Apply(23,[new PArg(0), new PArg(13)]), new Apply(32,[new PArg(13)]), new Apply(41,[new PArg(9), new PArg(12), new PArg(13)]), new Apply(42,[new PArg(10), new PArg(12), new PArg(13)]), new Apply(43,[new PArg(9), new PArg(14), new PArg(13)]), new Apply(44,[new PArg(10), new PArg(14), new PArg(13)]), new Apply(52,[new PArg(9)]), new Apply(53,[new PArg(10)])], 10:[new Apply(15,[]), new Apply(16,[]), new Apply(20,[]), new Apply(22,[]), new Apply(38,[]), new Apply(39,[]), new Apply(45,[]), new Apply(46,[]), new Apply(48,[]), new Apply(50,[]), new Apply(51,[]), new Apply(58,[]), new Apply(59,[])], 12:[new Coerce(1), new Coerce(2)], 13:[new Coerce(5), new Coerce(6), new Coerce(7)], 14:[new Coerce(3), new Coerce(4)]},[new CncFun("lindef Adjective",[0, 0, 0, 0, 0, 0, 0]), new CncFun("lindef Determiner",[0, 0, 0, 0]), new CncFun("lindef Noun",[0, 0, 0, 0]), new CncFun("lindef Sentence",[0]), new CncFun("lindef Verb",[0, 0, 0, 0, 0]), new CncFun("Available",[1, 2, 3, 4, 5, 6, 7]), new CncFun("Bulgarian",[8, 9, 10, 11]), new CncFun("Command",[12]), new CncFun("Command",[13]), new CncFun("Command",[14]), new CncFun("Command",[15]), new CncFun("CommandAdj",[16]), new CncFun("CommandAdj",[17]), new CncFun("CommandAdj",[18]), new CncFun("CommandAdj",[19]), new CncFun("Copy",[20, 21, 22, 23, 22]), new CncFun("Cut",[24, 25, 26, 27, 26]), new CncFun("Danish",[28, 29, 30, 31]), new CncFun("DefPlDet",[32, 33, 34, 35]), new CncFun("DefSgDet",[32, 36, 37, 36]), new CncFun("Delete",[38, 39, 40, 41, 40]), new CncFun("English",[42, 43, 44, 45]), new CncFun("Enter",[46, 47, 48, 49, 48]), new CncFun("ErrorMessage",[50]), new CncFun("Finnish",[51, 52, 53, 54]), new CncFun("Float_N",[55, 56, 57, 58]), new CncFun("French",[59, 60, 61, 62]), new CncFun("German",[63, 64, 65, 66]), new CncFun("IndefPlDet",[67, 68, 69, 68]), new CncFun("IndefSgDet",[70, 71, 72, 71]), new CncFun("Integer_N",[73, 74, 75, 76]), new CncFun("Italian",[77, 78, 79, 80]), new CncFun("Label",[81]), new CncFun("Language",[82, 83, 84, 85]), new CncFun("Next",[86, 87, 88, 89, 90, 91, 92]), new CncFun("Node",[93, 94, 95, 96]), new CncFun("Norwegian",[97, 98, 99, 100]), new CncFun("Page",[101, 102, 103, 104]), new CncFun("Parse",[105, 106, 107, 108, 107]), new CncFun("Paste",[109, 110, 111, 112, 111]), new CncFun("Previous",[113, 114, 115, 116, 117, 118, 119]), new CncFun("RandomlyCommand",[120]), new CncFun("RandomlyCommand",[121]), new CncFun("RandomlyCommand",[122]), new CncFun("RandomlyCommand",[123]), new CncFun("Redo",[124, 125, 126, 127, 126]), new CncFun("Refine",[128, 129, 130, 131, 130]), new CncFun("Refinement",[132, 133, 134, 135]), new CncFun("Replace",[136, 137, 138, 139, 138]), new CncFun("Russian",[140, 141, 142, 143]), new CncFun("Select",[144, 145, 146, 147, 146]), new CncFun("Show",[148, 149, 150, 151, 150]), new CncFun("SingleWordCommand",[152]), new CncFun("SingleWordCommand",[81]), new CncFun("Spanish",[153, 154, 155, 156]), new CncFun("String_N",[157, 158, 159, 160]), new CncFun("Swedish",[161, 162, 163, 164]), new CncFun("Tree",[165, 166, 167, 168]), new CncFun("Undo",[169, 170, 171, 172, 171]), new CncFun("Wrap",[173, 174, 175, 176, 175]), new CncFun("Wrapper",[177, 178, 179, 180])],[[new SymLit(0, 0)],[new SymKS("available")],[new SymKS("available's")],[new SymKS("more", "available")],[new SymKS("more", "available's")],[new SymKS("most", "available")],[new SymKS("most", "available's")],[new SymKS("availably")],[new SymKS("Bulgarian")],[new SymKS("Bulgarian's")],[new SymKS("Bulgarians")],[new SymKS("Bulgarians'")],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 0), new SymKS("yourself")],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 0)],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 2), new SymKS("yourself")],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 2)],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 0), new SymCat(3, 0), new SymKS("yourself")],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 0), new SymCat(3, 0)],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 0), new SymCat(3, 2), new SymKS("yourself")],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 0), new SymCat(3, 2)],[new SymKS("copy")],[new SymKS("copies")],[new SymKS("copied")],[new SymKS("copying")],[new SymKS("cut")],[new SymKS("cuts")],[new SymKS("cutted")],[new SymKS("cutting")],[new SymKS("Danish")],[new SymKS("Danish's")],[new SymKS("Danishes")],[new SymKS("Danishes'")],[new SymKS("the")],[new SymKS("they")],[new SymKS("theirs")],[new SymKS("them")],[new SymKS("it")],[new SymKS("its")],[new SymKS("delete")],[new SymKS("deletes")],[new SymKS("deleted")],[new SymKS("deleting")],[new SymKS("English")],[new SymKS("English's")],[new SymKS("Englishes")],[new SymKS("Englishes'")],[new SymKS("enter")],[new SymKS("enters")],[new SymKS("enterred")],[new SymKS("enterring")],[new SymKS("no"), new SymCat(0, 0), new SymCat(1, 2)],[new SymKS("Finnish")],[new SymKS("Finnish's")],[new SymKS("Finnishes")],[new SymKS("Finnishes'")],[new SymKS("float")],[new SymKS("float's")],[new SymKS("floats")],[new SymKS("floats'")],[new SymKS("French")],[new SymKS("French's")],[new SymKS("Frenches")],[new SymKS("Frenches'")],[new SymKS("German")],[new SymKS("German's")],[new SymKS("Germans")],[new SymKS("Germans'")],[],[new SymKS("ones")],[new SymKS("ones'")],[new SymKP(["a"],[new Alt(["a"],["eu", "Eu", "uni", "up"]), new Alt(["an"],["un"]), new Alt(["an"],["a", "e", "i", "o", "A", "E", "I", "O"]), new Alt(["an"],["SMS", "sms"])])],[new SymKS("one")],[new SymKS("one's")],[new SymKS("integer")],[new SymKS("integer's")],[new SymKS("integers")],[new SymKS("integers'")],[new SymKS("Italian")],[new SymKS("Italian's")],[new SymKS("Italians")],[new SymKS("Italians'")],[new SymCat(0, 0)],[new SymKS("language")],[new SymKS("language's")],[new SymKS("languages")],[new SymKS("languages'")],[new SymKS("next")],[new SymKS("next's")],[new SymKS("nexter")],[new SymKS("nexter's")],[new SymKS("nextest")],[new SymKS("nextest's")],[new SymKS("nextly")],[new SymKS("node")],[new SymKS("node's")],[new SymKS("nodes")],[new SymKS("nodes'")],[new SymKS("Norwegian")],[new SymKS("Norwegian's")],[new SymKS("Norwegians")],[new SymKS("Norwegians'")],[new SymKS("page")],[new SymKS("page's")],[new SymKS("pages")],[new SymKS("pages'")],[new SymKS("parse")],[new SymKS("parses")],[new SymKS("parsed")],[new SymKS("parsing")],[new SymKS("paste")],[new SymKS("pastes")],[new SymKS("pasted")],[new SymKS("pasting")],[new SymKS("previous")],[new SymKS("previous'")],[new SymKS("more", "previous")],[new SymKS("more", "previous'")],[new SymKS("most", "previous")],[new SymKS("most", "previous'")],[new SymKS("previously")],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 0), new SymKS("yourself", "at", "random")],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 0), new SymKS("at", "random")],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 2), new SymKS("yourself", "at", "random")],[new SymCat(0, 0), new SymCat(1, 0), new SymCat(2, 2), new SymKS("at", "random")],[new SymKS("redo")],[new SymKS("redoes")],[new SymKS("redoed")],[new SymKS("redoing")],[new SymKS("refine")],[new SymKS("refines")],[new SymKS("refined")],[new SymKS("refining")],[new SymKS("refinement")],[new SymKS("refinement's")],[new SymKS("refinements")],[new SymKS("refinements'")],[new SymKS("replace")],[new SymKS("replaces")],[new SymKS("replaced")],[new SymKS("replacing")],[new SymKS("Russian")],[new SymKS("Russian's")],[new SymKS("Russians")],[new SymKS("Russians'")],[new SymKS("select")],[new SymKS("selects")],[new SymKS("selected")],[new SymKS("selecting")],[new SymKS("show")],[new SymKS("shows")],[new SymKS("showed")],[new SymKS("showing")],[new SymCat(0, 0), new SymKS("yourself")],[new SymKS("Spanish")],[new SymKS("Spanish's")],[new SymKS("Spanishes")],[new SymKS("Spanishes'")],[new SymKS("string")],[new SymKS("string's")],[new SymKS("strings")],[new SymKS("strings'")],[new SymKS("Swedish")],[new SymKS("Swedish's")],[new SymKS("Swedishes")],[new SymKS("Swedishes'")],[new SymKS("tree")],[new SymKS("tree's")],[new SymKS("trees")],[new SymKS("trees'")],[new SymKS("undo")],[new SymKS("undoes")],[new SymKS("undoed")],[new SymKS("undoing")],[new SymKS("wrap")],[new SymKS("wraps")],[new SymKS("wrapped")],[new SymKS("wrapping")],[new SymKS("wrapper")],[new SymKS("wrapper's")],[new SymKS("wrappers")],[new SymKS("wrappers'")]],{Adjective:{s: 0, e: 0}, Determiner:{s: 1, e: 4}, Float:{s: -3, e: -3}, Int:{s: -2, e: -2}, Noun:{s: 5, e: 7}, Sentence:{s: 8, e: 8}, String:{s: -1, e: -1}, Verb:{s: 9, e: 10}, __gfVar:{s: -4, e: -4}}, 15)}); diff --git a/src/runtime/javascript/gfjseditor.js b/src/runtime/javascript/gfjseditor.js index 154d624cb..de0ad67fa 100644 --- a/src/runtime/javascript/gfjseditor.js +++ b/src/runtime/javascript/gfjseditor.js @@ -222,10 +222,10 @@ function getTree(tree, level) { htmlTree.push("
  • "); if (tree.hasChildren()) { htmlTree.push(""); } else { @@ -359,7 +359,7 @@ function editFrameKeyDown(me,lang,event) { else parseTrees = [new Fun(string)]; break; - default: parseTrees = grammar.concretes[lang].parser.parseString(string, node.cat); break; + default: parseTrees = grammar.concretes[lang].parseString(string, node.cat); break; } if (parseTrees.length == 1) { pushUndoClearRedo(); @@ -607,13 +607,8 @@ function showActions(caption) { actions.push(createAction("Wrap", "action", "SingleWordCommand Wrap", "W")); } - for (var i in grammar.concretes) { - if (grammar.concretes[i].parser) { - actions.push(createAction("Parse", "action", "Command Parse IndefSgDet String_N", "P")); - } else { actions.push(createAction("Parse", "unavailable", "Command Parse IndefSgDet String_N", "P")); } - break; - } - + actions.push(createAction("Parse", "action", "Command Parse IndefSgDet String_N", "P")); + if (node && !abstractNode.isComplete()) { actions.push(createAction("RandomNode", "action", "RandomlyCommand Refine DefSgDet Node", "N")); } diff --git a/src/runtime/javascript/gflib.js b/src/runtime/javascript/gflib.js index 03df363a4..97e98aab2 100644 --- a/src/runtime/javascript/gflib.js +++ b/src/runtime/javascript/gflib.js @@ -20,20 +20,18 @@ GFGrammar.prototype.translate = function (input, fromLang, toLang) { toConcs[toLang] = this.concretes[toLang]; } for (var c1 in fromConcs) { - var p = this.concretes[c1].parser; - if (p) { - var trees = p.parseString(input, this.abstract.startcat); - if (trees.length > 0) { - outputs[c1] = new Array(); - for (var i in trees) { - outputs[c1][i] = new Object(); - for (var c2 in toConcs) { - outputs[c1][i][c2] = this.concretes[c2].linearize(trees[i]); - } + var concrete = this.concretes[c1]; + var trees = concrete.parseString(input, this.abstract.startcat); + if (trees.length > 0) { + outputs[c1] = new Array(); + for (var i in trees) { + outputs[c1][i] = new Object(); + for (var c2 in toConcs) { + outputs[c1][i][c2] = this.concretes[c2].linearize(trees[i]); } } } - } + } return outputs; } @@ -50,7 +48,10 @@ String.prototype.setTag = function (tag) { this.tag = tag; }; /* Abstract syntax trees */ function Fun(name) { this.name = name; - this.args = copy_arguments(arguments, 1); + this.args = new Array(); + for (var i = 1; i < arguments.length; i++) { + this.args[i-1] = arguments[i]; + } } Fun.prototype.print = function () { return this.show(0); } ; Fun.prototype.show = function (prec) { @@ -98,7 +99,18 @@ Fun.prototype.isComplete = function() { } } ; Fun.prototype.isLiteral = function() { - return (/^[\"\d]/).test(this.name); + return (/^[\"\-\d]/).test(this.name); +} ; +Fun.prototype.isString = function() { + return (/^\".*\"$/).test(this.name); +} ; +Fun.prototype.isInt = function() { + return (/^\-?\d+$/).test(this.name); +} ; +Fun.prototype.isFloat = function() { + return (/^\-?\d*(\.\d*)?$/).test(this.name) && + this.name != "." && + this.name != "-."; } ; Fun.prototype.isEqual = function(obj) { if (this.name != obj.name) @@ -112,93 +124,6 @@ Fun.prototype.isEqual = function(obj) { return true; } -/* Concrete syntax terms */ - -function Arr() { this.arr = copy_arguments(arguments, 0); } -Arr.prototype.tokens = function() { return this.arr[0].tokens(); }; -Arr.prototype.sel = function(i) { return this.arr[i.toIndex()]; }; -Arr.prototype.setTag = function(tag) { - for (var i = 0, j = this.arr.length; i < j; i++) { - this.arr[i].setTag(tag); - } -}; - -function Seq() { this.seq = copy_arguments(arguments, 0); } -Seq.prototype.tokens = function() { - var xs = new Array(); - for (var i in this.seq) { - var ys = this.seq[i].tokens(); - for (var j in ys) { - xs.push(ys[j]); - } - } - return xs; -}; -Seq.prototype.setTag = function(tag) { - for (var i = 0, j = this.seq.length; i < j; i++) { - this.seq[i].setTag(tag); - } -}; - -function Variants() { this.variants = copy_arguments(arguments, 0); } -Variants.prototype.tokens = function() { return this.variants[0].tokens(); }; -Variants.prototype.sel = function(i) { return this.variants[0].sel(i); }; -Variants.prototype.toIndex = function() { return this.variants[0].toIndex(); }; -Variants.prototype.setTag = function(tag) { - for (var i = 0, j = this.variants.length; i < j; i++) { - this.variants[i].setTag(tag); - } -}; - -function Rp(index,value) { this.index = index; this.value = value; } -Rp.prototype.tokens = function() { return new Array(this.index.tokens()); }; -Rp.prototype.sel = function(i) { return this.value.arr[i.toIndex()]; }; -Rp.prototype.toIndex = function() { return this.index.toIndex(); }; -Rp.prototype.setTag = function(tag) { this.index.setTag(tag) }; - -function Suffix(prefix,suffix) { - this.prefix = new String(prefix); - if (prefix.tag) { this.prefix.tag = prefix.tag; } - this.suffix = suffix; -}; -Suffix.prototype.tokens = function() { - var xs = this.suffix.tokens(); - for (var i in xs) { - xs[i] = new String(this.prefix + xs[i]); - xs[i].setTag(this.prefix.tag); - } - return xs; -}; -Suffix.prototype.sel = function(i) { return new Suffix(this.prefix, this.suffix.sel(i)); }; -Suffix.prototype.setTag = function(tag) { if (!this.prefix.tag) { this.prefix.setTag(tag); } }; - -function Meta() { } -Meta.prototype.tokens = function() { - var newString = new String("?"); - newString.setTag(this.tag); - return new Array(newString); -}; -Meta.prototype.toIndex = function() { return 0; }; -Meta.prototype.sel = function(i) { return this; }; -Meta.prototype.setTag = function(tag) { if (!this.tag) { this.tag = tag; } }; - -function Str(value) { this.value = value; } -Str.prototype.tokens = function() { - var newString = new String(this.value); - newString.setTag(this.tag); - return new Array(newString); -}; -Str.prototype.setTag = function(tag) { if (!this.tag) { this.tag = tag; } }; - -function Int(value) { this.value = value; } -Int.prototype.tokens = function() { - var newString = new String(this.value.toString()); - newString.setTag(this.tag); - return new Array(newString); -}; -Int.prototype.toIndex = function() { return this.value; }; -Int.prototype.setTag = function(tag) { if (!this.tag) { this.tag = tag; } }; - /* Type annotation */ function GFAbstract(startcat, types) { @@ -284,47 +209,166 @@ function Type(args, cat) { /* Linearization */ -function GFConcrete(flags, rules, parser) { - this.flags = flags; - this.rules = rules; - if (parser) { - this.parser = parser; - } else { - this.parser = undefined; - } +function GFConcrete(flags, productions, functions, sequences, startCats, totalFIds) { + this.flags = flags; + this.productions = productions; + this.functions = functions; + this.sequences = sequences; + this.startCats = startCats; + this.totalFIds = totalFIds; + + this.pproductions = productions; + this.lproductions = new Object(); + + for (var fid in productions) { + for (var i in productions[fid]) { + var rule = productions[fid][i]; + + if (rule.id == "Apply") { + var fun = this.functions[rule.fun]; + var lproductions = this.lproductions; + + rule.fun = fun; + + var register = function (args, key, i) { + if (i < args.length) { + var c = 0; + var arg = args[i].fid; + + for (var k in productions[arg]) { + var rule = productions[arg][k]; + if (rule.id == "Coerce") { + register(args,key + "_" + rule.arg,i+1); + c++; + } + } + + if (c == 0) + register(args,key + "_" + arg,i+1); + } else { + var set = lproductions[key]; + if (set == null) { + set = new Array(); + lproductions[key] = set; + } + set.push({fun: fun, fid: fid}); + } + } + + register(rule.args,rule.fun.name,0); + } + } + } + + for (var i in functions) { + var fun = functions[i]; + for (var j in fun.lins) { + fun.lins[j] = sequences[fun.lins[j]]; + } + } } -GFConcrete.prototype.rule = function (name, cs) { - var r = this.rules[name]; - if (r) { - return this.rules[name](cs); +GFConcrete.prototype.linearizeSyms = function (tree, tag) { + var res = new Array(); + + if (tree.isString()) { + var sym = new SymKS(tree.name); + sym.tag = tag; + res.push({fid: -1, table: [[sym]]}); + } else if (tree.isInt()) { + var sym = new SymKS(tree.name); + sym.tag = tag; + res.push({fid: -2, table: [[sym]]}); + } else if (tree.isFloat()) { + var sym = new SymKS(tree.name); + sym.tag = tag; + res.push({fid: -3, table: [[sym]]}); + } else if (tree.isMeta()) { + // TODO: Use lindef here + var cat = this.startCats[tree.type]; + + var sym = new SymKS(tree.name); + sym.tag = tag; + + for (var fid = cat.s; fid <= cat.e; fid++) { + res.push({fid: fid, table: [[sym]]}); + } } else { - window.alert("Missing rule " + name); + var cs = new Array(); + for (var i in tree.args) { + // TODO: we should handle the case for nondeterministic linearization + cs.push(this.linearizeSyms(tree.args[i],tag + "-" + i)[0]); + } + var key = tree.name; + for (var i in cs) { + key = key + "_" + cs[i].fid + } + + for (var i in this.lproductions[key]) { + var rule = this.lproductions[key][i]; + var row = {fid: rule.fid, table: new Array()}; + for (var j in rule.fun.lins) { + var lin = rule.fun.lins[j]; + var toks = new Array(); + row.table[j] = toks; + + for (var k in lin) { + var sym = lin[k]; + switch (sym.id) { + case "Arg": + case "Lit": + var ts = cs[sym.i].table[sym.label]; + for (var l in ts) { + toks.push(ts[l]); + } + break; + case "KS": + case "KP": + toks.push(this.tagIt(sym,tag)); + break; + } + } + } + res.push(row); + } } + + return res; }; -GFConcrete.prototype.addRule = function (name, f) { this.rules[name] = f; }; -GFConcrete.prototype.lindef = function (cat, v) { return this.rules[cat]([new Str(v)]); } ; -GFConcrete.prototype.linearize = function (tree) { - return this.unlex(this.linearizeToTerm(tree).tokens()); +GFConcrete.prototype.syms2toks = function (syms) { + var ts = new Array(); + for (var i in syms) { + var sym = syms[i]; + switch (sym.id) { + case "KS": + for (var j in sym.tokens) { + ts.push(this.tagIt(sym.tokens[j],sym.tag)); + } + break; + case "KP": + for (var j in sym.tokens) { + ts.push(this.tagIt(sym.tokens[j],sym.tag)); + } + break; + } + } + return ts; }; -GFConcrete.prototype.linearizeToTerm = function (tree) { - if (tree.isMeta()) { - if (isUndefined(tree.type)) { - return new Meta(); - } else { - return this.lindef(tree.type, tree.name); - } - } else { - var cs = new Array(); - for (var i in tree.args) { - cs.push(this.linearizeToTerm(tree.args[i])); - } - if (tree.isLiteral()) { - return new Arr(new Str(tree.name)); - } else { - return this.rule(tree.name, cs); - } - } +GFConcrete.prototype.linearizeAll = function (tree) { + var res = this.linearizeSyms(tree,"0"); + for (var l in res) { + res[l] = this.unlex(this.syms2toks(res[l].table[0])); + } + + return res; }; +GFConcrete.prototype.linearize = function (tree) { + var res = this.linearizeSyms(tree,"0"); + return this.unlex(this.syms2toks(res[0].table[0])); +} +GFConcrete.prototype.tagAndLinearize = function (tree) { + var res = this.linearizeSyms(tree,"0"); + return this.syms2toks(res[0].table[0]); +} GFConcrete.prototype.unlex = function (ts) { if (ts.length == 0) { return ""; @@ -345,29 +389,20 @@ GFConcrete.prototype.unlex = function (ts) { } return s; }; -GFConcrete.prototype.tagAndLinearize = function (tree) { - return this.tagAndLinearizeToTerm(tree, "0").tokens(); -}; -GFConcrete.prototype.tagAndLinearizeToTerm = function (tree, route) { - if (tree.isMeta()) { - if (isUndefined(tree.type)) { - var newMeta = new Meta(); - newMeta.setTag(route); - return newMeta; - } else { - var newTerm = this.lindef(tree.type, tree.name); - newTerm.setTag(route); - return newTerm; - } - } else { - var cs = new Array(); - for (var i in tree.args) { - cs.push(this.tagAndLinearizeToTerm(tree.args[i], route + "-" + i)); - } - var newTerm = this.rule(tree.name, cs); - newTerm.setTag(route); - return newTerm; - } +GFConcrete.prototype.tagIt = function (obj, tag) { + if (isString(obj)) { + var o = new String(obj); + o.setTag(tag); + return o; + } else { + var me = arguments.callee; + if (arguments.length == 2) { + me.prototype = obj; + var o = new me(); + o.tag = tag; + return o; + } + } }; /* Utilities */ @@ -405,42 +440,12 @@ function dumpObject (obj) { } } - -function copy_arguments(args, start) { - var arr = new Array(); - for (var i = 0; i < args.length - start; i++) { - arr[i] = args[i + start]; - } - return arr; -} - /* ------------------------------------------------------------------------- */ /* -------------------------------- PARSING -------------------------------- */ /* ------------------------------------------------------------------------- */ -function Parser(productions, functions, sequences, startCats, totalCats) { - this.productions = productions; - this.functions = functions; - this.sequences = sequences; - this.startCats = startCats; - this.totalCats = totalCats; - - for (var fid in productions) { - for (var i in productions[fid]) { - var rule = productions[fid][i]; - rule.fun = functions[rule.fun]; - } - } - - for (var i in functions) { - var fun = functions[i]; - for (var j in fun.lins) { - fun.lins[j] = sequences[fun.lins[j]]; - } - } -} -Parser.prototype.showRules = function () { +GFConcrete.prototype.showRules = function () { var ruleStr = new Array(); ruleStr.push(""); for (var i = 0, j = this.rules.length; i < j; i++) { @@ -448,7 +453,7 @@ Parser.prototype.showRules = function () { } return ruleStr.join(""); }; -Parser.prototype.tokenize = function (string) { +GFConcrete.prototype.tokenize = function (string) { var inToken = false; var start, end; var tokens = new Array(); @@ -484,7 +489,7 @@ Parser.prototype.tokenize = function (string) { } return tokens; }; -Parser.prototype.parseString = function (string, cat) { +GFConcrete.prototype.parseString = function (string, cat) { var tokens = this.tokenize(string); var ps = new ParseState(this, cat); @@ -497,7 +502,7 @@ Parser.prototype.parseString = function (string, cat) { /** * Generate list of suggestions given an input string */ -Parser.prototype.complete = function (input, cat) { +GFConcrete.prototype.complete = function (input, cat) { // Parameter defaults if (input == null) input = ""; @@ -558,19 +563,19 @@ Parser.prototype.complete = function (input, cat) { return { 'consumed' : tokens, 'suggestions' : suggs }; } -// Rule Object Definition +// Apply Object Definition -function Rule(fun, args) { - this.id = "Rule"; +function Apply(fun, args) { + this.id = "Apply"; this.fun = fun; this.args = args; } -Rule.prototype.show = function (cat) { +Apply.prototype.show = function (cat) { var recStr = new Array(); recStr.push(cat, " -> ", fun.name, " [", this.args, "]"); return recStr.join(""); }; -Rule.prototype.isEqual = function (obj) { +Apply.prototype.isEqual = function (obj) { if (this.id != obj.id || this.fun != obj.fun || this.args.length != obj.args.length) return false; @@ -582,6 +587,12 @@ Rule.prototype.isEqual = function (obj) { return true; }; +function PArg() { + this.fid = arguments[arguments.length-1]; + if (arguments.length > 1) + this.hypos = arguments.slice(0,arguments.length-1); +} + // Coerce Object Definition function Coerce(arg) { @@ -618,7 +629,7 @@ Const.prototype.isEqual = function (obj) { return true; }; -function FFun(name,lins) { +function CncFun(name,lins) { this.name = name; this.lins = lins; } @@ -626,39 +637,39 @@ function FFun(name,lins) { // Definition of symbols present in linearization records // Object to represent argument projections in grammar rules -function Arg(i, label) { +function SymCat(i, label) { this.id = "Arg"; this.i = i; this.label = label; } -Arg.prototype.getId = function () { return this.id; }; -Arg.prototype.getArgNum = function () { return this.i }; -Arg.prototype.show = function () { +SymCat.prototype.getId = function () { return this.id; }; +SymCat.prototype.getArgNum = function () { return this.i }; +SymCat.prototype.show = function () { var argStr = new Array(); argStr.push(this.i, this.label); return argStr.join("."); }; // Object to represent terminals in grammar rules -function KS() { +function SymKS() { this.id = "KS"; this.tokens = arguments; } -KS.prototype.getId = function () { return this.id; }; -KS.prototype.show = function () { +SymKS.prototype.getId = function () { return this.id; }; +SymKS.prototype.show = function () { var terminalStr = new Array(); terminalStr.push('"', this.tokens, '"'); return terminalStr.join(""); }; // Object to represent pre in grammar rules -function KP(tokens,alts) { +function SymKP(tokens,alts) { this.id = "KP"; this.tokens = tokens; this.alts = alts; } -KP.prototype.getId = function () { return this.id; }; -KP.prototype.show = function () { +SymKP.prototype.getId = function () { return this.id; }; +SymKP.prototype.show = function () { var terminalStr = new Array(); terminalStr.push('"', this.tokens, '"'); return terminalStr.join(""); @@ -670,13 +681,13 @@ function Alt(tokens, prefixes) { } // Object to represent pre in grammar rules -function Lit(i,label) { +function SymLit(i,label) { this.id = "Lit"; this.i = i; this.label = label; } -Lit.prototype.getId = function () { return this.id; }; -Lit.prototype.show = function () { +SymLit.prototype.getId = function () { return this.id; }; +SymLit.prototype.show = function () { var argStr = new Array(); argStr.push(this.i, this.label); return argStr.join("."); @@ -729,15 +740,15 @@ Trie.prototype.isEmpty = function() { return true; } -function ParseState(parser, startCat) { - this.parser = parser; +function ParseState(concrete, startCat) { + this.concrete = concrete; this.startCat = startCat; this.items = new Trie(); - this.chart = new Chart(parser); + this.chart = new Chart(concrete); var items = new Array(); - var fids = parser.startCats[startCat]; + var fids = concrete.startCats[startCat]; if (fids != null) { var fid; for (fid = fids.s; fid <= fids.e; fid++) { @@ -841,11 +852,11 @@ ParseState.prototype.extractTrees = function() { ); - var totalCats = this.parser.totalCats; + var totalFIds = this.concrete.totalFIds; var forest = this.chart.forest; function go(fid) { - if (fid < totalCats) { + if (fid < totalFIds) { return [new Fun("?")]; } else { var trees = new Array(); @@ -861,7 +872,7 @@ ParseState.prototype.extractTrees = function() { var arg_ts = new Array(); for (var k in rule.args) { arg_ix[k] = 0; - arg_ts[k] = go(rule.args[k]); + arg_ts[k] = go(rule.args[k].fid); } while (true) { @@ -893,7 +904,7 @@ ParseState.prototype.extractTrees = function() { var trees = new Array(); - var fids = this.parser.startCats[this.startCat]; + var fids = this.concrete.startCats[this.startCat]; if (fids != null) { var fid0; for (fid0 = fids.s; fid0 <= fids.e; fid0++) { @@ -936,7 +947,7 @@ ParseState.prototype.process = function (agenda,literalCallback,tokenCallback) { if (item.dot < lin.length) { var sym = lin[item.dot]; switch (sym.id) { - case "Arg": var fid = item.args[sym.i]; + case "Arg": var fid = item.args[sym.i].fid; var label = sym.label; var items = this.chart.lookupAC(fid,label); @@ -975,7 +986,7 @@ ParseState.prototype.process = function (agenda,literalCallback,tokenCallback) { tokenCallback(alt.tokens, pitem); } break; - case "Lit": var fid = item.args[sym.i]; + case "Lit": var fid = item.args[sym.i].fid; var rules = this.chart.forest[fid]; if (rules != null) { tokenCallback(rules[0].toks, item.shiftOverTokn()); @@ -1004,7 +1015,7 @@ ParseState.prototype.process = function (agenda,literalCallback,tokenCallback) { } this.chart.insertPC(item.fid,item.lbl,item.offset,fid); - this.chart.forest[fid] = [new Rule(item.fun,item.args)]; + this.chart.forest[fid] = [new Apply(item.fun,item.args)]; } else { var labels = this.chart.labelsAC(fid); if (labels != null) { @@ -1014,7 +1025,7 @@ ParseState.prototype.process = function (agenda,literalCallback,tokenCallback) { } var rules = this.chart.forest[fid]; - var rule = new Rule(item.fun,item.args); + var rule = new Apply(item.fun,item.args); var isMember = false; for (var j in rules) { @@ -1030,16 +1041,16 @@ ParseState.prototype.process = function (agenda,literalCallback,tokenCallback) { } } -function Chart(parser) { +function Chart(concrete) { this.active = new Object(); this.actives = new Array(); this.passive = new Object(); this.forest = new Object(); - this.nextId = parser.totalCats; + this.nextId = concrete.totalFIds; this.offset = 0; - for (var fid in parser.productions) { - this.forest[fid] = parser.productions[fid]; + for (var fid in concrete.pproductions) { + this.forest[fid] = concrete.pproductions[fid]; } } Chart.prototype.lookupAC = function (fid,label) { @@ -1096,7 +1107,7 @@ Chart.prototype.expandForest = function (fid) { for (var i in rules0) { var rule = rules0[i]; switch (rule.id) { - case "Rule": rules.push(rule); break; + case "Apply": rules.push(rule); break; case "Coerce": go(forest[rule.arg]); break; } } @@ -1129,9 +1140,9 @@ ActiveItem.prototype.shiftOverArg = function (i,fid) { for (var k in this.args) { nargs[k] = this.args[k]; } - nargs[i] = fid; + nargs[i] = new PArg(fid); return new ActiveItem(this.offset,this.dot+1,this.fun,this.seq,nargs,this.fid,this.lbl); } ActiveItem.prototype.shiftOverTokn = function () { return new ActiveItem(this.offset,this.dot+1,this.fun,this.seq,this.args,this.fid,this.lbl); -} \ No newline at end of file +} diff --git a/src/runtime/javascript/grammar.js b/src/runtime/javascript/grammar.js index a5859bd46..9e246db50 100644 --- a/src/runtime/javascript/grammar.js +++ b/src/runtime/javascript/grammar.js @@ -1 +1 @@ -var Food = new GFGrammar(new GFAbstract("Comment",{Boring: new Type([], "Quality"), Cheese: new Type([], "Kind"), Delicious: new Type([], "Quality"), Expensive: new Type([], "Quality"), Fish: new Type([], "Kind"), Fresh: new Type([], "Quality"), Pred: new Type(["Item", "Quality"], "Comment"), Italian: new Type([], "Quality"), Mod: new Type(["Quality", "Kind"], "Kind"), That: new Type(["Kind"], "Item"), This: new Type(["Kind"], "Item"), Very: new Type(["Quality"], "Quality"), Warm: new Type([], "Quality"), Wine: new Type([], "Kind")}),{FoodEng: new GFConcrete({},{Boring: function(cs){return new Arr(new Str("boring"));}, Cheese: function(cs){return new Arr(new Str("cheese"));}, Delicious: function(cs){return new Arr(new Str("delicious"));}, Expensive: function(cs){return new Arr(new Str("expensive"));}, Fish: function(cs){return new Arr(new Str("fish"));}, Fresh: function(cs){return new Arr(new Str("fresh"));}, Pred: function(cs){return new Arr(new Seq(Food.concretes["FoodEng"].rule("_6", cs), new Str("is"), Food.concretes["FoodEng"].rule("_7", cs)));}, Italian: function(cs){return new Arr(new Str("Italian"));}, Mod: function(cs){return new Arr(new Seq(Food.concretes["FoodEng"].rule("_6", cs), Food.concretes["FoodEng"].rule("_7", cs)));}, That: function(cs){return new Arr(new Seq(new Str("that"), Food.concretes["FoodEng"].rule("_6", cs)));}, This: function(cs){return new Arr(new Seq(new Str("this"), Food.concretes["FoodEng"].rule("_6", cs)));}, Very: function(cs){return new Arr(new Seq(new Str("very"), Food.concretes["FoodEng"].rule("_6", cs)));}, Warm: function(cs){return new Arr(new Str("warm"));}, Wine: function(cs){return new Arr(new Str("wine"));}, _21: function(cs){return new Arr(cs[0]);}, _6: function(cs){return cs[0].sel(new Int(0));}, _7: function(cs){return cs[1].sel(new Int(0));}, Item: function(cs){return Food.concretes["FoodEng"].rule("_21", cs);}, Kind: function(cs){return Food.concretes["FoodEng"].rule("_21", cs);}, Comment: function(cs){return Food.concretes["FoodEng"].rule("_21", cs);}, Quality: function(cs){return Food.concretes["FoodEng"].rule("_21", cs);}, "Int": function(cs){return new Arr(cs[0]);}, "Float": function(cs){return new Arr(cs[0]);}, "String": function(cs){return new Arr(cs[0]);}}, new Parser({0:[new Rule(9,[1]), new Rule(10,[1])], 1:[new Rule(1,[]), new Rule(4,[]), new Rule(8,[3, 1]), new Rule(13,[])], 2:[new Rule(6,[0, 3])], 3:[new Rule(0,[]), new Rule(2,[]), new Rule(3,[]), new Rule(5,[]), new Rule(7,[]), new Rule(11,[3]), new Rule(12,[])]},[new FFun("Boring",[0]), new FFun("Cheese",[1]), new FFun("Delicious",[2]), new FFun("Expensive",[3]), new FFun("Fish",[4]), new FFun("Fresh",[5]), new FFun("Pred",[6]), new FFun("Italian",[7]), new FFun("Mod",[8]), new FFun("That",[9]), new FFun("This",[10]), new FFun("Very",[11]), new FFun("Warm",[12]), new FFun("Wine",[13])],[[new KS("boring")],[new KS("cheese")],[new KS("delicious")],[new KS("expensive")],[new KS("fish")],[new KS("fresh")],[new Arg(0, 0), new KS("is"), new Arg(1, 0)],[new KS("Italian")],[new Arg(0, 0), new Arg(1, 0)],[new KS("that"), new Arg(0, 0)],[new KS("this"), new Arg(0, 0)],[new KS("very"), new Arg(0, 0)],[new KS("warm")],[new KS("wine")]],{Float:{s: -3, e: -3}, Int:{s: -2, e: -2}, Item:{s: 0, e: 0}, Kind:{s: 1, e: 1}, Comment:{s: 2, e: 2}, Quality:{s: 3, e: 3}, String:{s: -1, e: -1}, __gfVar:{s: -4, e: -4}}, 5)), FoodIta: new GFConcrete({},{Boring: function(cs){return new Arr(new Str("noioso"));}, Cheese: function(cs){return new Arr(new Str("formaggio"));}, Delicious: function(cs){return new Arr(new Str("delizioso"));}, Expensive: function(cs){return new Arr(new Str("caro"));}, Fish: function(cs){return new Arr(new Str("pesce"));}, Fresh: function(cs){return new Arr(new Str("fresco"));}, Pred: function(cs){return new Arr(new Seq(Food.concretes["FoodIta"].rule("_6", cs), new Str("è"), Food.concretes["FoodIta"].rule("_7", cs)));}, Italian: function(cs){return new Arr(new Str("italiano"));}, Mod: function(cs){return new Arr(new Seq(Food.concretes["FoodIta"].rule("_7", cs), Food.concretes["FoodIta"].rule("_6", cs)));}, That: function(cs){return new Arr(new Seq(new Str("quel"), Food.concretes["FoodIta"].rule("_6", cs)));}, This: function(cs){return new Arr(new Seq(new Str("questo"), Food.concretes["FoodIta"].rule("_6", cs)));}, Very: function(cs){return new Arr(new Seq(new Str("molto"), Food.concretes["FoodIta"].rule("_6", cs)));}, Warm: function(cs){return new Arr(new Str("caldo"));}, Wine: function(cs){return new Arr(new Str("vino"));}, _21: function(cs){return new Arr(cs[0]);}, _6: function(cs){return cs[0].sel(new Int(0));}, _7: function(cs){return cs[1].sel(new Int(0));}, Item: function(cs){return Food.concretes["FoodIta"].rule("_21", cs);}, Kind: function(cs){return Food.concretes["FoodIta"].rule("_21", cs);}, Comment: function(cs){return Food.concretes["FoodIta"].rule("_21", cs);}, Quality: function(cs){return Food.concretes["FoodIta"].rule("_21", cs);}, "Int": function(cs){return new Arr(cs[0]);}, "Float": function(cs){return new Arr(cs[0]);}, "String": function(cs){return new Arr(cs[0]);}}, new Parser({0:[new Rule(9,[1]), new Rule(10,[1])], 1:[new Rule(1,[]), new Rule(4,[]), new Rule(8,[3, 1]), new Rule(13,[])], 2:[new Rule(6,[0, 3])], 3:[new Rule(0,[]), new Rule(2,[]), new Rule(3,[]), new Rule(5,[]), new Rule(7,[]), new Rule(11,[3]), new Rule(12,[])]},[new FFun("Boring",[0]), new FFun("Cheese",[1]), new FFun("Delicious",[2]), new FFun("Expensive",[3]), new FFun("Fish",[4]), new FFun("Fresh",[5]), new FFun("Pred",[6]), new FFun("Italian",[7]), new FFun("Mod",[8]), new FFun("That",[9]), new FFun("This",[10]), new FFun("Very",[11]), new FFun("Warm",[12]), new FFun("Wine",[13])],[[new KS("noioso")],[new KS("formaggio")],[new KS("delizioso")],[new KS("caro")],[new KS("pesce")],[new KS("fresco")],[new Arg(0, 0), new KS("è"), new Arg(1, 0)],[new KS("italiano")],[new Arg(1, 0), new Arg(0, 0)],[new KS("quel"), new Arg(0, 0)],[new KS("questo"), new Arg(0, 0)],[new KS("molto"), new Arg(0, 0)],[new KS("caldo")],[new KS("vino")]],{Float:{s: -3, e: -3}, Int:{s: -2, e: -2}, Item:{s: 0, e: 0}, Kind:{s: 1, e: 1}, Comment:{s: 2, e: 2}, Quality:{s: 3, e: 3}, String:{s: -1, e: -1}, __gfVar:{s: -4, e: -4}}, 5))}); +var Foods = new GFGrammar(new GFAbstract("Phrase",{Boring: new Type([], "Quality"), Cheese: new Type([], "Kind"), Delicious: new Type([], "Quality"), Expensive: new Type([], "Quality"), Fish: new Type([], "Kind"), Fresh: new Type([], "Quality"), Is: new Type(["Item", "Quality"], "Phrase"), Italian: new Type([], "Quality"), Pizza: new Type([], "Kind"), QKind: new Type(["Quality", "Kind"], "Kind"), That: new Type(["Kind"], "Item"), These: new Type(["Kind"], "Item"), This: new Type(["Kind"], "Item"), Those: new Type(["Kind"], "Item"), Very: new Type(["Quality"], "Quality"), Warm: new Type([], "Quality"), Wine: new Type([], "Kind")}),{FoodsEng: new GFConcrete({},{0:[new Apply(15,[new PArg(2)]), new Apply(17,[new PArg(2)])], 1:[new Apply(16,[new PArg(2)]), new Apply(18,[new PArg(2)])], 2:[new Apply(5,[]), new Apply(8,[]), new Apply(13,[]), new Apply(14,[new PArg(4), new PArg(2)]), new Apply(21,[])], 3:[new Apply(10,[new PArg(0), new PArg(4)]), new Apply(11,[new PArg(1), new PArg(4)])], 4:[new Apply(4,[]), new Apply(6,[]), new Apply(7,[]), new Apply(9,[]), new Apply(12,[]), new Apply(19,[new PArg(4)]), new Apply(20,[])]},[new CncFun("lindef Item",[0]), new CncFun("lindef Kind",[0, 0]), new CncFun("lindef Phrase",[0]), new CncFun("lindef Quality",[0]), new CncFun("Boring",[1]), new CncFun("Cheese",[2, 3]), new CncFun("Delicious",[4]), new CncFun("Expensive",[5]), new CncFun("Fish",[6, 6]), new CncFun("Fresh",[7]), new CncFun("Is",[8]), new CncFun("Is",[9]), new CncFun("Italian",[10]), new CncFun("Pizza",[11, 12]), new CncFun("QKind",[13, 14]), new CncFun("That",[15]), new CncFun("These",[16]), new CncFun("This",[17]), new CncFun("Those",[18]), new CncFun("Very",[19]), new CncFun("Warm",[20]), new CncFun("Wine",[21, 22])],[[new SymLit(0, 0)],[new SymKS("boring")],[new SymKS("cheese")],[new SymKS("cheeses")],[new SymKS("delicious")],[new SymKS("expensive")],[new SymKS("fish")],[new SymKS("fresh")],[new SymCat(0, 0), new SymKS("is"), new SymCat(1, 0)],[new SymCat(0, 0), new SymKS("are"), new SymCat(1, 0)],[new SymKS("Italian")],[new SymKS("pizza")],[new SymKS("pizzas")],[new SymCat(0, 0), new SymCat(1, 0)],[new SymCat(0, 0), new SymCat(1, 1)],[new SymKS("that"), new SymCat(0, 0)],[new SymKS("these"), new SymCat(0, 1)],[new SymKS("this"), new SymCat(0, 0)],[new SymKS("those"), new SymCat(0, 1)],[new SymKS("very"), new SymCat(0, 0)],[new SymKS("warm")],[new SymKS("wine")],[new SymKS("wines")]],{Float:{s: -3, e: -3}, Int:{s: -2, e: -2}, Item:{s: 0, e: 1}, Kind:{s: 2, e: 2}, Phrase:{s: 3, e: 3}, Quality:{s: 4, e: 4}, String:{s: -1, e: -1}, __gfVar:{s: -4, e: -4}}, 6)});