summaryrefslogtreecommitdiff
path: root/libcmd
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2016-05-17 23:33:39 +0100
committerFreeArtMan <dos21h@gmail.com>2016-05-17 23:33:39 +0100
commit4baa01f8cd595cb0517d8f7f665d5be92528b6c2 (patch)
tree3f717f18473d7caef1375cdd2e1a60b1a0c55bca /libcmd
parent852c7ad1af2e3283425dccd79b0923b7df12a388 (diff)
downloadihe-4baa01f8cd595cb0517d8f7f665d5be92528b6c2.tar.gz
ihe-4baa01f8cd595cb0517d8f7f665d5be92528b6c2.zip
Fixed cmd line parsing when 1 symbols strings wherent recognized
Diffstat (limited to 'libcmd')
-rw-r--r--libcmd/cmd_parse.c108
-rw-r--r--libcmd/cmd_parse.ragel10
2 files changed, 60 insertions, 58 deletions
diff --git a/libcmd/cmd_parse.c b/libcmd/cmd_parse.c
index ee6b3ca..84ec41a 100644
--- a/libcmd/cmd_parse.c
+++ b/libcmd/cmd_parse.c
@@ -7,6 +7,9 @@
#define TADD(T,S,E,SZ) {cmd_tok_t *t=cmd_tok_create(S,E,SZ,T);cmd_tok_add(tl,t);tl=tl->next;}
//#define TADD(T,S,E)
+//#define PR_TK_DBG(S) printf(S);fwrite(ts,1,te-ts,stdout);printf("\n");
+#define PR_TK_DBG(S) ;
+
char *new_string( const char *start, const char *end )
{
int str_s = end-start+1;
@@ -27,7 +30,7 @@ int print_token( char *s, char *e, int tok)
-#line 31 "cmd_parse.c"
+#line 34 "cmd_parse.c"
static const char _cmd_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3, 1, 4, 1, 5, 1, 6, 1,
@@ -35,81 +38,80 @@ static const char _cmd_actions[] = {
};
static const char _cmd_key_offsets[] = {
- 0, 0, 8, 17, 19, 25, 31, 43,
- 47, 49, 51, 57
+ 0, 0, 8, 17, 19, 25, 37, 40,
+ 44, 46, 48, 54
};
static const char _cmd_trans_keys[] = {
32, 39, 48, 57, 65, 90, 97, 122,
32, 34, 39, 48, 57, 65, 90, 97,
122, 48, 49, 48, 57, 65, 70, 97,
- 102, 48, 57, 65, 90, 97, 122, 32,
- 34, 48, 59, 9, 10, 49, 57, 65,
- 90, 97, 122, 98, 120, 48, 57, 48,
- 57, 48, 49, 48, 57, 65, 70, 97,
- 102, 48, 57, 65, 90, 97, 122, 0
+ 102, 32, 34, 48, 59, 9, 10, 49,
+ 57, 65, 90, 97, 122, 32, 9, 10,
+ 98, 120, 48, 57, 48, 57, 48, 49,
+ 48, 57, 65, 70, 97, 102, 48, 57,
+ 65, 90, 97, 122, 0
};
static const char _cmd_single_lengths[] = {
- 0, 2, 3, 0, 0, 0, 4, 2,
+ 0, 2, 3, 0, 0, 4, 1, 2,
0, 0, 0, 0
};
static const char _cmd_range_lengths[] = {
- 0, 3, 3, 1, 3, 3, 4, 1,
+ 0, 3, 3, 1, 3, 4, 1, 1,
1, 1, 3, 3
};
static const char _cmd_index_offsets[] = {
- 0, 0, 6, 13, 15, 19, 23, 32,
- 36, 38, 40, 44
+ 0, 0, 6, 13, 15, 19, 28, 31,
+ 35, 37, 39, 43
};
static const char _cmd_indicies[] = {
0, 0, 0, 0, 0, 1, 0, 2,
0, 0, 0, 0, 1, 4, 3, 5,
- 5, 5, 3, 6, 6, 6, 1, 7,
- 8, 9, 11, 7, 10, 12, 12, 1,
- 14, 15, 10, 13, 10, 13, 4, 16,
- 5, 5, 5, 17, 6, 6, 6, 18,
- 0
+ 5, 5, 3, 6, 7, 8, 10, 6,
+ 9, 11, 11, 1, 6, 6, 12, 14,
+ 15, 9, 13, 9, 13, 4, 16, 5,
+ 5, 5, 17, 11, 11, 11, 18, 0
};
static const char _cmd_trans_targs[] = {
- 2, 0, 6, 6, 9, 10, 11, 6,
- 1, 7, 8, 6, 5, 6, 3, 4,
- 6, 6, 6
+ 2, 0, 5, 5, 9, 10, 6, 1,
+ 7, 8, 5, 11, 5, 5, 3, 4,
+ 5, 5, 5
};
static const char _cmd_trans_actions[] = {
- 0, 0, 9, 21, 0, 0, 0, 7,
- 0, 5, 0, 11, 0, 15, 0, 0,
- 17, 13, 19
+ 0, 0, 7, 21, 0, 0, 0, 0,
+ 5, 0, 9, 0, 13, 15, 0, 0,
+ 17, 11, 19
};
static const char _cmd_to_state_actions[] = {
- 0, 0, 0, 0, 0, 0, 1, 0,
+ 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0
};
static const char _cmd_from_state_actions[] = {
- 0, 0, 0, 0, 0, 0, 3, 0,
+ 0, 0, 0, 0, 0, 3, 0, 0,
0, 0, 0, 0
};
static const char _cmd_eof_trans[] = {
- 0, 0, 0, 4, 4, 0, 0, 14,
+ 0, 0, 0, 4, 4, 0, 13, 14,
14, 17, 18, 19
};
-static const int cmd_start = 6;
-static const int cmd_first_final = 6;
+static const int cmd_start = 5;
+static const int cmd_first_final = 5;
static const int cmd_error = 0;
-static const int cmd_en_main = 6;
+static const int cmd_en_main = 5;
-#line 53 "cmd_parse.ragel"
+#line 56 "cmd_parse.ragel"
int parse_cmd( cmd_tok_t *tl, const char *str )
@@ -126,7 +128,7 @@ int parse_cmd( cmd_tok_t *tl, const char *str )
*/
-#line 130 "cmd_parse.c"
+#line 132 "cmd_parse.c"
{
cs = cmd_start;
ts = 0;
@@ -134,9 +136,9 @@ int parse_cmd( cmd_tok_t *tl, const char *str )
act = 0;
}
-#line 69 "cmd_parse.ragel"
+#line 72 "cmd_parse.ragel"
-#line 140 "cmd_parse.c"
+#line 142 "cmd_parse.c"
{
int _klen;
unsigned int _trans;
@@ -157,7 +159,7 @@ _resume:
#line 1 "NONE"
{ts = p;}
break;
-#line 161 "cmd_parse.c"
+#line 163 "cmd_parse.c"
}
}
@@ -228,38 +230,38 @@ _eof_trans:
{te = p+1;}
break;
case 3:
-#line 42 "cmd_parse.ragel"
- {te = p+1;}
+#line 46 "cmd_parse.ragel"
+ {te = p+1;{PR_TK_DBG("str = ");TADD(CMDT_STR, ts,te,te-ts);}}
break;
case 4:
-#line 43 "cmd_parse.ragel"
- {te = p+1;{printf("str = ");fwrite(ts,1,te-ts,stdout);printf("\n");TADD(CMDT_STR,ts,te,te-ts);}}
+#line 49 "cmd_parse.ragel"
+ {te = p+1;{PR_TK_DBG("sep = ");TADD(CMDT_SP, ts,te,te-ts);}}
break;
case 5:
-#line 46 "cmd_parse.ragel"
- {te = p+1;{printf("sep = ");fwrite(ts,1,te-ts,stdout);printf("\n");TADD(CMDT_SP,ts,te,te-ts);}}
+#line 44 "cmd_parse.ragel"
+ {te = p;p--;{PR_TK_DBG("hex = ");TADD(CMDT_HEX, ts,te,te-ts);}}
break;
case 6:
-#line 41 "cmd_parse.ragel"
- {te = p;p--;{printf("hex = ");fwrite(ts,1,te-ts,stdout);printf("\n");TADD(CMDT_HEX,ts,te,te-ts);}}
+#line 45 "cmd_parse.ragel"
+ {te = p;p--;{PR_TK_DBG("sp = ");}}
break;
case 7:
-#line 44 "cmd_parse.ragel"
- {te = p;p--;{printf("dec = ");fwrite(ts,1,te-ts,stdout);printf("\n");TADD(CMDT_INT,ts,te,te-ts);}}
+#line 47 "cmd_parse.ragel"
+ {te = p;p--;{PR_TK_DBG("dec = ");TADD(CMDT_INT, ts,te,te-ts);}}
break;
case 8:
-#line 45 "cmd_parse.ragel"
- {te = p;p--;{printf("bin = ");fwrite(ts,1,te-ts,stdout);printf("\n");TADD(CMDT_BIN,ts,te,te-ts);}}
+#line 48 "cmd_parse.ragel"
+ {te = p;p--;{PR_TK_DBG("bin = ");TADD(CMDT_BIN, ts,te,te-ts);}}
break;
case 9:
-#line 47 "cmd_parse.ragel"
- {te = p;p--;{printf("wrd = ");fwrite(ts,1,te-ts,stdout);printf("\n");TADD(CMDT_WORD,ts,te,te-ts);}}
+#line 50 "cmd_parse.ragel"
+ {te = p;p--;{PR_TK_DBG("wrd = ");TADD(CMDT_WORD,ts,te,te-ts);}}
break;
case 10:
-#line 44 "cmd_parse.ragel"
- {{p = ((te))-1;}{printf("dec = ");fwrite(ts,1,te-ts,stdout);printf("\n");TADD(CMDT_INT,ts,te,te-ts);}}
+#line 47 "cmd_parse.ragel"
+ {{p = ((te))-1;}{PR_TK_DBG("dec = ");TADD(CMDT_INT, ts,te,te-ts);}}
break;
-#line 263 "cmd_parse.c"
+#line 265 "cmd_parse.c"
}
}
@@ -272,7 +274,7 @@ _again:
#line 1 "NONE"
{ts = 0;}
break;
-#line 276 "cmd_parse.c"
+#line 278 "cmd_parse.c"
}
}
@@ -292,7 +294,7 @@ _again:
_out: {}
}
-#line 70 "cmd_parse.ragel"
+#line 73 "cmd_parse.ragel"
if ( cs == cmd_error )
{
diff --git a/libcmd/cmd_parse.ragel b/libcmd/cmd_parse.ragel
index 85aa7d8..dd5ff13 100644
--- a/libcmd/cmd_parse.ragel
+++ b/libcmd/cmd_parse.ragel
@@ -5,8 +5,8 @@
#define TADD(T,S,E,SZ) {cmd_tok_t *t=cmd_tok_create(S,E,SZ,T);cmd_tok_add(tl,t);tl=tl->next;}
//#define TADD(T,S,E)
-#define PR_TK_DBG(S) printf(S);fwrite(ts,1,te-ts,stdout);printf("\n");
-//#define PR_TK_DBG(S)
+//#define PR_TK_DBG(S) printf(S);fwrite(ts,1,te-ts,stdout);printf("\n");
+#define PR_TK_DBG(S) ;
char *new_string( const char *start, const char *end )
{
@@ -36,13 +36,13 @@ int print_token( char *s, char *e, int tok)
binary = '0b' [0-1]+;
string = ('"' ([a-zA-Z0-9' '])+ '"');
seperate = ';';
- word = [a-zA-Z] ([a-zA-Z0-9])+;
+ word = [a-zA-Z] ([a-zA-Z0-9])*;
- sp = (' ' | '\t' | '\n');
+ sp = (' ' | '\t' | '\n')*;
main := |*
hex {PR_TK_DBG("hex = ");TADD(CMDT_HEX, ts,te,te-ts);};
- sp {};
+ sp {PR_TK_DBG("sp = ");};
string {PR_TK_DBG("str = ");TADD(CMDT_STR, ts,te,te-ts);};
decimal {PR_TK_DBG("dec = ");TADD(CMDT_INT, ts,te,te-ts);};
binary {PR_TK_DBG("bin = ");TADD(CMDT_BIN, ts,te,te-ts);};