Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
xdrm-brackets | bae568e3f5 | |
xdrm-brackets | ad1bec2a30 | |
xdrm-brackets | cb29813cd2 | |
xdrm-brackets | 6996441429 |
13
src/linter.c
13
src/linter.c
|
@ -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,14 +101,14 @@ 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(" (*) final_state: %d/%d\n", array.dCurrent, array.dFinal);
|
||||
|
|
82
src/test
82
src/test
|
@ -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: '}'
|
Loading…
Reference in New Issue