return (STRING);
}
[ \t]*#.* { return (COMMENT); }
-[a-zA-Z_][a-zA-Z0-9_\-]* {
+[a-zA-Z_][a-zA-Z0-9_\-]+ {
yylval.node.ident = strdup(yytext);
yylval.node.nodes = NULL;
yylval.node.string = NULL;
yylval.node.type = 'I';
return (IDENTIFIER);
}
--?[0-9]+(\.[0-9]+)? {
+[YTNF] {
+ yylval.node.ident = NULL;
+ yylval.node.nodes = NULL;
+ yylval.node.string = NULL;
+ yylval.node.logical = (yytext[0] == 'Y' || yytext[0] == 'T') ? 0xff : 0;
+ yylval.node.type = 'L';
+ return (LOGICAL);
+}
+[\+-]?[0-9]+(\.[0-9]+)? {
yylval.node.ident = NULL;
yylval.node.nodes = NULL;
yylval.node.string = NULL;
#include <stdio.h>
%}
-%token IDENTIFIER STRING NUMBER SPACE COMMENT
+%token IDENTIFIER STRING NUMBER SPACE COMMENT LOGICAL
%start command
%union {
int errnum;
char type;
double number;
+ unsigned char logical;
struct Node** nodes;
} node;
}
$<node>$.string = $<node>1.string;
$<node>$.nodes = $<node>1.nodes;
$<node>$.ident = $<node>1.ident;
+ $<node>$.number = $<node>1.number;
$<node>$.type = $<node>1.type;
+ $<node>$.logical = $<node>1.logical;
}
| NUMBER {
$<node>$.string = $<node>1.string;
$<node>$.ident = $<node>1.ident;
$<node>$.number = $<node>1.number;
$<node>$.type = $<node>1.type;
+ $<node>$.logical = $<node>1.logical;
+ }
+ | LOGICAL {
+ $<node>$.string = $<node>1.string;
+ $<node>$.nodes = $<node>1.nodes;
+ $<node>$.ident = $<node>1.ident;
+ $<node>$.number = $<node>1.number;
+ $<node>$.type = $<node>1.type;
+ $<node>$.logical = $<node>1.logical;
}
| command {
$<node>$ = $<node>1;
$<node>$.ident = $<node>2.ident;
$<node>$.number = $<node>2.number;
$<node>$.type = $<node>2.type;
+ $<node>$.logical = $<node>2.logical;
}
| SPACE argument {
$<node>$.string = $<node>2.string;
$<node>$.ident = $<node>2.ident;
$<node>$.number = $<node>2.number;
$<node>$.type = $<node>2.type;
+ $<node>$.logical = $<node>2.logical;
}
| argument SPACE {
$<node>$.string = $<node>1.string;
$<node>$.ident = $<node>1.ident;
$<node>$.number = $<node>1.number;
$<node>$.type = $<node>1.type;
+ $<node>$.logical = $<node>1.logical;
}
| argument {
$<node>$.string = $<node>1.string;
$<node>$.ident = $<node>1.ident;
$<node>$.number = $<node>1.number;
$<node>$.type = $<node>1.type;
+ $<node>$.logical = $<node>1.logical;
}
;
$<node>$.nodes[0]->nodes = NULL;
$<node>$.nodes[0]->ident = NULL;
$<node>$.nodes[0]->string = NULL;
+ $<node>$.nodes[0]->logical = $<node>1.logical;
$<node>$.nodes[0]->number = $<node>1.number;
$<node>$.nodes[0]->type = $<node>1.type;
if($<node>1.ident != NULL) $<node>$.nodes[0]->ident = __dw_strdup($<node>1.ident);
$<node>$.nodes[i]->nodes = NULL;
$<node>$.nodes[i]->ident = NULL;
$<node>$.nodes[i]->string = NULL;
+ $<node>$.nodes[i]->logical = $<node>3.logical;
$<node>$.nodes[i]->number = $<node>3.number;
$<node>$.nodes[i]->type = $<node>3.type;
if($<node>3.ident != NULL) $<node>$.nodes[i]->ident = __dw_strdup($<node>3.ident);
char* fieldtypes = malloc(1);
fieldtypes[0] = 0;
char* name = NULL;
+ bool used = false;
if(__dw_strcaseequ(node->ident, "version")) {
newnode->string = __dw_strdup(dataworks_get_version());
+ used = true;
}
if(node->nodes != NULL) {
for(i = 0; node->nodes[i] != NULL; i++) {
printf("%s", r->string);
}
fflush(stdout);
+ used = true;
} else if(__dw_strcaseequ(node->ident, "concat")) {
if(r->string != NULL) {
if(newnode->string == NULL) {
newnode->string = __dw_strcat(tmp, r->string);
free(tmp);
}
+ used = true;
} else if(__dw_strcaseequ(node->ident, "use")) {
if(name != NULL) {
newnode->errnum = DW_ERR_EXEC_TOO_MANY_ARGUMENTS;
if(name == NULL) {
name = __dw_strdup(r->string);
}
+ used = true;
} else if(__dw_strcaseequ(node->ident, "create_table")) {
if(name == NULL) {
name = __dw_strdup(r->string);
}
free(val);
}
+ used = true;
} else {
int j;
for(i = 0; fields[i] != NULL; i++) free(fields[i]);
} else {
newnode->errnum = DW_ERR_EXEC_INSUFFICIENT_ARGUMENTS;
}
- } else {
+ } else if(!used) {
newnode->errnum = DW_ERR_EXEC_UNKNOWN_METHOD;
}
if(name != NULL) free(name);