Compare commits

..

4 Commits
test ... master

Author SHA1 Message Date
xdrm-brackets bae568e3f5 minmod 2017-05-16 10:50:01 +02:00
xdrm-brackets ad1bec2a30 minfix 2017-05-16 10:49:00 +02:00
xdrm-brackets cb29813cd2 re-added escapable characters 2017-05-16 10:47:36 +02:00
xdrm-brackets 6996441429 [big update] json array works 2017-05-16 10:44:04 +02:00
2 changed files with 12 additions and 89 deletions

View File

@ -57,17 +57,22 @@ int main(int argc, char* argv[]){
addDot(&string); // q0
addDot(&string); // q1
addDot(&string); // q2
addDot(&string); // q3
addStringTransition(&string, "\"\0"); // s0
addStringTransition(&string, "\\\0"); // s1
addRangeTransition(&string, "az\0"); // r0
addRangeTransition(&string, "AZ\0"); // r1
addRangeTransition(&string, "09\0"); // r2
addListTransition(&string, "-_\0"); // l0
addListTransition(&string, "rn\"\0"); // l1
linkDots(&string, 0, 1, STRING_T, 0); // q0 --s0--> q1
linkDots(&string, 1, 1, LIST_T, 0); // q0 --l0--> q1
linkDots(&string, 1, 1, RANGE_T, 0); // q0 --r0--> q1
linkDots(&string, 1, 1, RANGE_T, 1); // q0 --r1--> q1
linkDots(&string, 1, 1, RANGE_T, 2); // q0 --r2--> q1
linkDots(&string, 1, 2, STRING_T, 0); // q1 --s0--> q2
linkDots(&string, 1, 2, STRING_T, 1); // q1 --s1--> q2
linkDots(&string, 2, 1, LIST_T, 1); // q2 --l1--> q1
linkDots(&string, 1, 3, STRING_T, 0); // q1 --s0--> q3
struct Automate value = createAutomate("value");
@ -96,16 +101,16 @@ int main(int argc, char* argv[]){
linkDots(&array, 0, 1, STRING_T, 0); // q0 --s0--> q1
linkDots(&array, 1, 2, AUTOMATE_T, 0); // q1 --a0--> q2
linkDots(&array, 2, 1, STRING_T, 2); // q2 --s2--> q1
linkDots(&array, 1, 3, AUTOMATE_T, 0); // q1 --a0--> q3
linkDots(&array, 1, 3, STRING_T, 1); // q1 --s1--> q3
char str[40] = {0};
strcpy(str, "[null, \"abc\", \"def\"]\0");
char str[80] = {0};
strcpy(str, "[null, \"abc\", \"def\", false, true, 12, -1.2, .54, -.3, 5., \"bla\\\"blo\\rbla\\n\"]\0");
clock_t start, stop;
unsigned int browsed = 0;
start = clock(); browsed = browse(&array, str, 0); stop = clock();
debug(array);
printf("browse '%s' : %d/%d\n", str, browsed, (int) strlen(str));
printf("browse '%s': %d/%d\n", str, browsed, (int) strlen(str));
printf(" (*) final_state: %d/%d\n", array.dCurrent, array.dFinal);
printf(" (*) in %d steps\n", array.steps);
printf(" (*) in %.3lf seconds\n\n", (double)(stop-start)/CLOCKS_PER_SEC);

View File

@ -1,82 +0,0 @@
>>> [browsing number]
> q0 --l0--> q1 ?
< yes
> q1 --a0--> q2 ?
>>> [browsing positive]
> q0 --a0--> q1 ?
>>> [browsing digit]
> q0 --r0--> q0 ?
< yes
> q1 --r0--> q0 ?
< yes
> q2 --r0--> q0 ?
< yes
> q3 --r0--> q0 ?
< yes
>>> [done digit = 0/0]
automate leads us (positive) from state 0 to 1
< yes
> q1 --s0--> q2 ?
> q1 --s0--> q3 ?
< not
* back to q0:1
> q0 --s0--> q2 ?
> q0 --a0--> q3 ?
>>> [browsing digit]
> q0 --r0--> q0 ?
< yes
> q1 --r0--> q0 ?
< yes
> q2 --r0--> q0 ?
< yes
> q3 --r0--> q0 ?
< yes
>>> [done digit = 0/0]
automate leads us (positive) from state 0 to 3
< yes
< not
* back to q0:3
>>> [done positive = 0/3]
< not
* back to q0:1
> q0 --a0--> q2 ?
>>> [browsing positive]
> q0 --a0--> q1 ?
>>> [browsing digit]
> q0 --r0--> q0 ?
< not
* back to q0:1
>>> [done digit = 0/0]
automate leads us (positive) from state 0 to 1
< yes
> q1 --s0--> q2 ?
> q1 --s0--> q3 ?
< not
* back to q0:1
> q0 --s0--> q2 ?
> q0 --a0--> q3 ?
>>> [browsing digit]
> q0 --r0--> q0 ?
< not
* back to q0:1
>>> [done digit = 0/0]
automate leads us (positive) from state 0 to 3
< yes
< not
* back to q0:3
>>> [done positive = 0/3]
< not
* back to q0:2
>>> [done number = 0/2]
browse '+1234' : 0/5
(*) final_state: 0/2
(*) in 20 steps
(*) in 0.000 seconds
line/0: '<?php'
line/1: 'require_once 'blabla.php';'
line/1: 'echo "blabla";'
line/0: ''
line/1: 'function sadsad(){'
line/2: '$var = 12;'
line/1: '}'