diff options
-rw-r--r-- | properties.l | 2 | ||||
-rw-r--r-- | properties.y | 11 | ||||
-rw-r--r-- | test/test.properties | 14 |
3 files changed, 25 insertions, 2 deletions
diff --git a/properties.l b/properties.l index 50acbd7..b1b8617 100644 --- a/properties.l +++ b/properties.l @@ -5,7 +5,7 @@ %% -=|: return DIV; +=|: yylval.value = strdup(yytext); return DIV; ^[ \t]*[a-zA-Z0-9\.]*[ \t]* yylval.value = strdup(trim(yytext)); return KEY; \n ; /* Ignores empty lines with a single newline */ ^[ \t]*#.* ; /* Ignores comments */ diff --git a/properties.y b/properties.y index 7bdd864..9cf460e 100644 --- a/properties.y +++ b/properties.y @@ -36,7 +36,16 @@ property: KEY DIV value { } ; -value: VALUE { +value: DIV { + $$.value = cpyval(2, sizeof(char), $1.value); + } + | value DIV { + char *s = strdup($$.value); + $$.value = calloc(strlen(s) + strlen($2.value) + 1, sizeof(char)); + strcat($$.value, s); + strcat($$.value, $2.value); + } + | VALUE { $$.value = cpyval(2, sizeof(char), $1.value); } | value VALUE { diff --git a/test/test.properties b/test/test.properties index e34ebc9..66953ca 100644 --- a/test/test.properties +++ b/test/test.properties @@ -31,3 +31,17 @@ key2.1 = key3 = A value # A value beginning with tabs key3.1 = A value + +# A value containing an equal +key4 = A value with an = symbol +key4.1 = = (equal is a symbol) +# A value, just an equal +key4.2 = = + +# Tests with a colon +key5:value5 +key5.1 : value5.1 +key5.2 : +key5.3 :: +key5.2 : : symbol +key5.2 : := symbols
\ No newline at end of file |