Skip to content

Commit

Permalink
wip #8 fixed size structs work again in ide and type-changed bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
zippy committed Oct 19, 2015
1 parent 5a5c8a5 commit dc9cc8d
Show file tree
Hide file tree
Showing 6 changed files with 544 additions and 497 deletions.
4 changes: 2 additions & 2 deletions src/base_defs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ Symbol: STRUCTURE_OR,[(STRUCTURE_DEF,STRUCTURE_DEF)];
Symbol: STRUCTURE_ZERO_OR_MORE,STRUCTURE_DEF;
Symbol: STRUCTURE_ONE_OR_MORE,STRUCTURE_DEF;
Symbol: STRUCTURE_ZERO_OR_ONE,STRUCTURE_DEF;
Symbol: SYMBOLS,LIST;
Symbol: SYMBOL_DECLARATION,TREE;
Symbol: SYMBOL_STRUCTURE,STRUCTURE;
Symbol: SYMBOL_LABEL,CSTRING;
Symbol: SYMBOL_DECLARATION,[(SYMBOL_LABEL,SYMBOL_STRUCTURE)];
Symbol: SYMBOLS,[*SYMBOL_DECLARATION];

Symbol: BOOLEAN,BIT;
Symbol: SEMTREX_MATCH_PATH,TREE_PATH; Path to symbol matched by semtrex
Expand Down
6 changes: 4 additions & 2 deletions src/base_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ void base_defs() {
sYs(SYS_CONTEXT,STRUCTURE_ZERO_OR_MORE,STRUCTURE_DEF);
sYs(SYS_CONTEXT,STRUCTURE_ONE_OR_MORE,STRUCTURE_DEF);
sYs(SYS_CONTEXT,STRUCTURE_ZERO_OR_ONE,STRUCTURE_DEF);
sYs(SYS_CONTEXT,SYMBOLS,LIST);
sY(SYS_CONTEXT,SYMBOL_DECLARATION,TREE);
sY(SYS_CONTEXT,SYMBOL_STRUCTURE,STRUCTURE);
sY(SYS_CONTEXT,SYMBOL_LABEL,CSTRING);
sTs(SYS_CONTEXT,TUPLE_OF_SYMBOL_LABEL_AND_SYMBOL_STRUCTURE,sT_SEQ(2,sT_SYM(SYMBOL_LABEL),sT_SYM(SYMBOL_STRUCTURE)));
sY(SYS_CONTEXT,SYMBOL_DECLARATION,TUPLE_OF_SYMBOL_LABEL_AND_SYMBOL_STRUCTURE);
sTs(SYS_CONTEXT,ZERO_OR_MORE_OF_SYMBOL_DECLARATION,sT_STAR(sT_SYM(SYMBOL_DECLARATION)));
sYs(SYS_CONTEXT,SYMBOLS,ZERO_OR_MORE_OF_SYMBOL_DECLARATION);
sY(SYS_CONTEXT,BOOLEAN,BIT);
sY(SYS_CONTEXT,SEMTREX_MATCH_PATH,TREE_PATH);
sY(SYS_CONTEXT,SEMTREX_SYMBOL_LITERAL,TREE);
Expand Down
8 changes: 6 additions & 2 deletions src/base_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ enum SYSSymbolIDs {
STRUCTURE_ZERO_OR_ONE_ID,
STRUCTURE_LABEL_ID,
STRUCTURE_DEFINITION_ID,
SYMBOL_DECLARATION_ID,
SYMBOL_STRUCTURE_ID,
SYMBOL_LABEL_ID,
SYMBOL_DECLARATION_ID,
BOOLEAN_ID,
SEMTREX_MATCH_PATH_ID,
SEMTREX_SYMBOL_LITERAL_ID,
Expand Down Expand Up @@ -196,9 +196,9 @@ enum SYSSymbolIDs {
#define STRUCTURE_ZERO_OR_ONE G_contexts[SYS_CONTEXT].symbols[STRUCTURE_ZERO_OR_ONE_ID]
#define STRUCTURE_LABEL G_contexts[SYS_CONTEXT].symbols[STRUCTURE_LABEL_ID]
#define STRUCTURE_DEFINITION G_contexts[SYS_CONTEXT].symbols[STRUCTURE_DEFINITION_ID]
#define SYMBOL_DECLARATION G_contexts[SYS_CONTEXT].symbols[SYMBOL_DECLARATION_ID]
#define SYMBOL_STRUCTURE G_contexts[SYS_CONTEXT].symbols[SYMBOL_STRUCTURE_ID]
#define SYMBOL_LABEL G_contexts[SYS_CONTEXT].symbols[SYMBOL_LABEL_ID]
#define SYMBOL_DECLARATION G_contexts[SYS_CONTEXT].symbols[SYMBOL_DECLARATION_ID]
#define BOOLEAN G_contexts[SYS_CONTEXT].symbols[BOOLEAN_ID]
#define SEMTREX_MATCH_PATH G_contexts[SYS_CONTEXT].symbols[SEMTREX_MATCH_PATH_ID]
#define SEMTREX_SYMBOL_LITERAL G_contexts[SYS_CONTEXT].symbols[SEMTREX_SYMBOL_LITERAL_ID]
Expand Down Expand Up @@ -370,6 +370,8 @@ enum SYSStructureIDs {
ONE_OR_MORE_OF_STRUCTURE_DEF_ID,
ONE_OR_MORE_OF_STRUCTURE_SYMBOL_ID,
PAIR_OF_STRUCTURE_DEF_ID,
TUPLE_OF_SYMBOL_LABEL_AND_SYMBOL_STRUCTURE_ID,
ZERO_OR_MORE_OF_SYMBOL_DECLARATION_ID,
SIGNATURE_PART_ID,
SEQUENCE_ID,
PROTOCOL_STEP_ID,
Expand Down Expand Up @@ -407,6 +409,8 @@ enum SYSStructureIDs {
#define ONE_OR_MORE_OF_STRUCTURE_DEF G_contexts[SYS_CONTEXT].structures[ONE_OR_MORE_OF_STRUCTURE_DEF_ID]
#define ONE_OR_MORE_OF_STRUCTURE_SYMBOL G_contexts[SYS_CONTEXT].structures[ONE_OR_MORE_OF_STRUCTURE_SYMBOL_ID]
#define PAIR_OF_STRUCTURE_DEF G_contexts[SYS_CONTEXT].structures[PAIR_OF_STRUCTURE_DEF_ID]
#define TUPLE_OF_SYMBOL_LABEL_AND_SYMBOL_STRUCTURE G_contexts[SYS_CONTEXT].structures[TUPLE_OF_SYMBOL_LABEL_AND_SYMBOL_STRUCTURE_ID]
#define ZERO_OR_MORE_OF_SYMBOL_DECLARATION G_contexts[SYS_CONTEXT].structures[ZERO_OR_MORE_OF_SYMBOL_DECLARATION_ID]
#define SIGNATURE_PART G_contexts[SYS_CONTEXT].structures[SIGNATURE_PART_ID]
#define SEQUENCE G_contexts[SYS_CONTEXT].structures[SEQUENCE_ID]
#define PROTOCOL_STEP G_contexts[SYS_CONTEXT].structures[PROTOCOL_STEP_ID]
Expand Down
2 changes: 1 addition & 1 deletion web/css/ceptr.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ltsymbols,ltparams {margin-left: 10px;}


.TE sem surface {
min-width: 20px;
min-width: 50px;
display: inline-block;
background-color: royalblue;
max-width: 400px;
Expand Down
58 changes: 45 additions & 13 deletions web/js/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,52 @@ var JQ = $; //jquery if needed for anything complicated, trying to not have dep
}
}
else if (sem.type === SEM_TYPE_SYMBOL) {
var symbols = LABEL_TABLE[def.structure].symbols;
// if structure has no symbols it's system defined so create a surface
// or an unknown treenode in the case of LIST or TREE structures
if (!symbols) {
if (def.structure == "TREE" || def.structure == "LIST") {
var children = $.getOrCreate('children',sem_elem);
children.innerHTML="<sem><label>--unknown--</label></sem>";
var sdef = LABEL_TABLE[def.structure].def;
var symbols;
var structure_type;
// the simple cases are just symbols or sequences of symbols
if (getSemName(sdef.sem) === "STRUCTURE_SYMBOL") {
var s_name = getSemName(sdef.surface);
if (s_name === "NULL_SYMBOL") {
structure_type = "base";
}
else {
$.remove('children',sem_elem);
var surface = $.getOrCreate('surface',sem_elem);
surface.innerHTML = "";
surface.setAttribute('contenteditable', 'true');
symbols = [getSemName(sdef.surface)];
structure_type = "fixed";
}
}
else if (getSemName(sdef.sem) === "STRUCTURE_SEQUENCE") {
var s = [];
structure_type = "fixed";
sdef.children.forEach(function(c){
if (getSemName(c.sem) === "STRUCTURE_SYMBOL") {
s.push(getSemName(c.surface));
}
else {structure_type = "complex"};
});
if (structure_type == "fixed") symbols = s;
}
else {
structure_type = "complex";
}

if (structure_type == "base") {
$.remove('children',sem_elem);
var surface = $.getOrCreate('surface',sem_elem);
surface.innerHTML = "";
surface.setAttribute('contenteditable', 'true');
}
else if (structure_type === "fixed") {
$.remove('surface',sem_elem);
var children = $.getOrCreate('children',sem_elem);
children.innerHTML = "";
symbols.forEach(function(s){
var child_sem = $.create('sem',{inside:children});
setupSem.call(me,s,child_sem,true,sem);
});
} else if (structure_type === "complex") {
var children = $.getOrCreate('children',sem_elem);
children.innerHTML="<sem><label>--unknown--</label></sem>";
}
}
}
Expand All @@ -243,7 +266,16 @@ var JQ = $; //jquery if needed for anything complicated, trying to not have dep
function close_a(e) {
//if the new label is defined and different reset everything
if (LABEL_TABLE[input.value] != undefined && label.innerHTML != input.value) {
setupSem.call(me,input.value,label.parentNode,false,undefined);
var parent_sem_id = label.parentNode.parentNode.parentNode.getAttribute("semid");
var parent_sem;
if (parent_sem_id) {
parent_sem_id = parent_sem_id.split('.');
parent_sem = {};
parent_sem.ctx = parent_sem_id[0];
parent_sem.type = parent_sem_id[1];
parent_sem.ctx = parent_sem_id[2];
}
setupSem.call(me,input.value,label.parentNode,false,parent_sem);
}
$.show(label);
var p = input.parentNode;
Expand Down Expand Up @@ -439,7 +471,7 @@ var JQ = $; //jquery if needed for anything complicated, trying to not have dep
Tnew(parts,LABEL_TABLE["STRUCTURE_SYMBOL"].sem,symbols[i]);
s.push(getSemName(symbols[i]));
}
LABEL_TABLE[label]= {"sem":sem,type:'structure',symbols:s};
LABEL_TABLE[label]= {"sem":sem,type:'structure',symbols:s,def:def.children[1]};
STRUCTURES.push(label);
if (_.lt_elem) {
var lt = makeLabelTableElem(label,LABEL_TABLE[label]);
Expand Down
Loading

0 comments on commit dc9cc8d

Please sign in to comment.