Commit 14c82955 authored by Aayush's avatar Aayush

suggested changes done in parser and ascii_art UI

parent 6b121e84
Pipeline #1572 failed with stage
in 0 seconds
......@@ -73,8 +73,7 @@
"mknob_steps": "# of steps",
"mknob_steps_tt": "number of dial positions for the knob",
"mknob_size": "size",
"mknob_size_tt": "size of the knob",
"submit_tt": "submit ascii_art to parser"
"mknob_size_tt": "size of the knob"
}
},
"gatom": {
......@@ -279,6 +278,10 @@
},
"canvas": {
"paste_clipboard_prompt": "Warnung: Sie sind dabei, Pd-Code einzufügen, der außerhalb von Pd erstellt wurde. Möchten Sie fortfahren?",
"ascii_art": {
"submit": "Submit Button",
"submit_tt": "submit ascii_art to parser"
},
"save_dialog": {
"prompt": "Speichern der Änderungen in",
"yes": "Ja",
......
......@@ -72,8 +72,7 @@
"mknob_steps": "# of steps",
"mknob_steps_tt": "number of dial positions for the knob",
"mknob_size": "size",
"mknob_size_tt": "size of the knob",
"submit_tt": "submit ascii_art to parser"
"mknob_size_tt": "size of the knob"
}
},
"gatom": {
......@@ -278,6 +277,10 @@
},
"canvas": {
"paste_clipboard_prompt": "Warning: you are about to paste Pd code that came from somewhere outside of Pd. Do you want to continue?",
"ascii_art": {
"submit": "Submit Button",
"submit_tt": "submit ascii_art to parser"
},
"save_dialog": {
"prompt": "Do you want to save the changes you made in",
"yes": "Yes",
......
......@@ -9,7 +9,7 @@
//for tracking connection path
function tracking_connection(curr_row, curr_col, next_row, next_col ,
string_array ,visited_array) {
var next_character,curr_character;
var next_character,curr_character,end_index;
curr_character = string_array[curr_row][curr_col];
next_character = string_array[next_row][next_col];
......@@ -35,7 +35,7 @@ function tracking_connection(curr_row, curr_col, next_row, next_col ,
next_row, next_col-1 , string_array ,visited_array);
}
break;
case "+" : if (character == "|") {
case "+" : if (curr_character == "|") {
if (string_array[next_row][next_col+1] == "-") {
// go in right direction
end_index = tracking_connection( next_row, next_col,
......@@ -45,20 +45,20 @@ function tracking_connection(curr_row, curr_col, next_row, next_col ,
end_index = tracking_connection( next_row, next_col,
next_row, next_col-1 , string_array ,visited_array);
}
} else if (character == "-") {
} else if (curr_character == "-") {
// Character following "+" will be "|" and it point to down direction
end_index = tracking_connection( next_row, next_col,
next_row+1, next_col , string_array ,visited_array);
}
break;
case "X" : if (character == "\\") {
case "X" : if (curr_character == "\\") {
// go bottom right
end_index = tracking_connection(next_row, next_col,
next_row+1, next_col+1 , string_array ,visited_array);
// for the next use of "X"
visited_array[next_row][next_col] = 0;
} else if (character == "/") {
} else if (curr_character == "/") {
end_index = tracking_connection(next_row,next_col,
next_row+1, next_col-1); // go bottom left
visited_array[next_row][next_column] = 0;
......@@ -90,8 +90,7 @@ function parse_ascii_art(ascii_art) {
i,
j,
temp_index,
start_index,
start;
start_index;
string_array.push([]);
visited_array.push([]);
......@@ -101,9 +100,12 @@ function parse_ascii_art(ascii_art) {
for (i = 0, j = 0 ; i < ascii_art.length ; i++, j++) {
var array=[];
//reading the character of string
var temp = ascii_art[i] ;
var temp = ascii_art[i],
array = [],
s_temp,
start;
string_array[row][j]=temp;
visited_array[row][j]=0;
......@@ -136,7 +138,7 @@ function parse_ascii_art(ascii_art) {
characters_stack.pop();
if (characters_stack.length == 0) {
s_temp = ascii_art.slice(start+1,i-1);
s_temp = ascii_art.slice(start+1,i);
obj_msg_array.push({index1:start_index, index2:temp_index,
type:1, string:s_temp});
state ="valid";
......@@ -146,7 +148,7 @@ function parse_ascii_art(ascii_art) {
characters_stack.pop();
if (characters_stack.length == 0) {
s_temp = ascii_art.slice(start+1,i-1);
s_temp = ascii_art.slice(start+1,i);
obj_msg_array.push({index1:start_index, index2:temp_index,
type:0, string:s_temp});
state = "valid";
......@@ -166,9 +168,10 @@ function parse_ascii_art(ascii_art) {
// Finding the connection's end points
for (i = 0 ; i < row ; i++) {
for (j = 0 ; j < string_array[i].length ; j++) {
var flag = 1;
// visited_array to travel a connection path only once
var temp = string_array[i][j];
var temp = string_array[i][j],
flag = 1,
end_index;
if (visited_array[i][j] == 0) {
switch(temp) {
......@@ -195,13 +198,13 @@ function parse_ascii_art(ascii_art) {
// be a single element connection
case "X": start_index = new INDEX(i, j);
end_index = new INDEX(i, j);
visited_array[i][j]=1;
visited_array[i][j] = 1;
break;
default : flag = 0;
visited_array[i][j]=1;
visited_array[i][j] = 1;
break;
}
visited_array[i][j]=1;
visited_array[i][j] = 1;
}
if (flag == 1) {
......@@ -213,18 +216,18 @@ function parse_ascii_art(ascii_art) {
//Finding the mapping between connections and Objects/Messages
for (i = 0 ; i< connections_array.length ; i++) {
start_index = connections_array[i].index1;
end_index = connections_array[i].index2;
max_distance1 = Infinity;
max_distance2 = Infinity;
inlet_object_index=0;
outlet_object_index=0;
start_point = 0;
end_point = 0;
var start_index = connections_array[i].index1,
end_index = connections_array[i].index2,
max_distance1 = Infinity,
max_distance2 = Infinity,
inlet_object_index=0,
outlet_object_index=0,
start_point = 0,
end_point = 0,
state_flag = 0;
for (j = 0 ; j < obj_msg_array.length ; j++) {
start = obj_msg_array[j].index1;
var start = obj_msg_array[j].index1,
end = obj_msg_array[j].index2;
if ( start_index.x == end.x ) {
......@@ -262,8 +265,9 @@ function parse_ascii_art(ascii_art) {
{
state= "valid";
} else {
state = "invalid"
state = "invalid";
}
objects_connections_map.push({start_object:outlet_object_index,
end_object:inlet_object_index,
start_point:start_point,
......@@ -271,21 +275,19 @@ function parse_ascii_art(ascii_art) {
}
var pd_message = "#N Canvas 400 800 12";
var pd_message = "";
for ( i = 0; i < obj_msg_array.length ; i++) {
type = obj_msg_array[i].type;
x1 = obj_msg_array[i].index1.x;
y1 = obj_msg_array[i].index1.y;
var type = obj_msg_array[i].type,
x1 = obj_msg_array[i].index1.x,
y1 = obj_msg_array[i].index1.y,
str = obj_msg_array[i].string;
str.replace(";\n"," ");
point_x = y1*20 + 100;
var point_x = y1*20 + 100,
point_y = x1*20 + 50;
point_x = point_x.toString();
point_x = point_x.toString(),
point_y = point_y.toString();
if ( type == 1 ) {
......@@ -304,7 +306,6 @@ function parse_ascii_art(ascii_art) {
+ objects_connections_map[i].end_point + ";\n";
pd_message = pd_message + str;
}
alert(pd_message);
var parser_data = {pd_message:pd_message,
state:state};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment