diff options
author | sanine <sanine.not@pm.me> | 2023-01-18 16:55:01 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-01-18 16:55:01 -0600 |
commit | 21afbb0644edc06fa47d29b847b4958d317b6a60 (patch) | |
tree | b0b59710cf83abc6b0dfc833a3cc835bb18c1127 /yy/kalmia.y | |
parent | 5d2e5a312ba73bd48913e9ac5babe1c644997b3e (diff) |
parse param nodesyacc
Diffstat (limited to 'yy/kalmia.y')
-rw-r--r-- | yy/kalmia.y | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/yy/kalmia.y b/yy/kalmia.y index 0d8b16f..48db26e 100644 --- a/yy/kalmia.y +++ b/yy/kalmia.y @@ -19,9 +19,14 @@ struct ka_float_array_t { char *id; - size_t count; + size_t count; /* required */ double *buf; }; + + struct ka_param_t { + char *name; + char *type; /* required */ + }; } %parse-param { struct kalmia_t *result } %code { @@ -38,8 +43,10 @@ } while(0) void kai_abortf_(YYLTYPE *yyllocp, const char *fmt, ...); - /* float arrays */ - int kai_set_float_array_attrs(struct ka_float_array_t *a, char *id, char *count); + /* attribute setters */ + int kai_set_float_array_attrs( + struct ka_float_array_t *a, + char *id, char *count); #define KAI_WRAP(call) \ do { \ @@ -59,6 +66,7 @@ char *sval; char cval; struct ka_float_array_t float_array; + struct ka_param_t param; } %token PROLOG @@ -68,14 +76,18 @@ %token <sval> TEXT %token <lval> INTEGER %token <dval> DOUBLE -%token DATE; +%token DATE %token <float_array> FLOAT_ARRAY %type <float_array> float_array %type <float_array> float_array_start %type <float_array> float_array_attributes -%token ID_ATTR COUNT_ATTR +%token PARAM +%type <param> param +%type <param> param_attrs + +%token ID_ATTR COUNT_ATTR NAME_ATTR TYPE_ATTR %type <sval> attr %% @@ -93,6 +105,7 @@ element: | start_tag end_tag | start_tag content end_tag | float_array + | param ; content: @@ -127,6 +140,7 @@ attribute: ATTR attr { printf("attribute: %s=%s\n", $1, $2); } | ID_ATTR attr | COUNT_ATTR attr + | NAME_ATTR attr ; @@ -165,6 +179,25 @@ float_array_attributes: { KAI_WRAP(kai_set_float_array_attrs(&$$, $2, $4)); } ; + +param: + S_TAG_OPEN PARAM param_attrs EMPTY_TAG_CLOSE + { + $$ = $3; + printf("param[name='%s', type='%s']\n", $$.name, $$.type); + } + ; + +param_attrs: + TYPE_ATTR attr + { $$.name = NULL; $$.type = $2; } + | TYPE_ATTR attr NAME_ATTR attr + { $$.name = $4; $$.type = $2; } + | NAME_ATTR attr TYPE_ATTR attr + { $$.name = $2; $$.type = $4; } + ; + + attr: '=' '"' TEXT '"' { $$ = $3; } ; |