summaryrefslogtreecommitdiff
path: root/main/ast_expr2.y
diff options
context:
space:
mode:
Diffstat (limited to 'main/ast_expr2.y')
-rw-r--r--main/ast_expr2.y37
1 files changed, 33 insertions, 4 deletions
diff --git a/main/ast_expr2.y b/main/ast_expr2.y
index 7eba6d165..76fe16005 100644
--- a/main/ast_expr2.y
+++ b/main/ast_expr2.y
@@ -284,6 +284,7 @@ static struct val *make_str __P((const char *));
static struct val *op_and __P((struct val *, struct val *));
static struct val *op_colon __P((struct val *, struct val *));
static struct val *op_eqtilde __P((struct val *, struct val *));
+static struct val *op_tildetilde __P((struct val *, struct val *));
static struct val *op_div __P((struct val *, struct val *));
static struct val *op_eq __P((struct val *, struct val *));
static struct val *op_ge __P((struct val *, struct val *));
@@ -354,18 +355,16 @@ extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t));
%left <val> TOK_PLUS TOK_MINUS
%left <val> TOK_MULT TOK_DIV TOK_MOD
%right <val> TOK_COMPL
-%left <val> TOK_COLON TOK_EQTILDE
+%left <val> TOK_COLON TOK_EQTILDE TOK_TILDETILDE
%left <val> TOK_RP TOK_LP
-
%token <val> TOKEN
%type <arglist> arglist
%type <val> start expr
-
%destructor { free_value($$); } expr TOKEN TOK_COND TOK_COLONCOLON TOK_OR TOK_AND TOK_EQ
TOK_GT TOK_LT TOK_GE TOK_LE TOK_NE TOK_PLUS TOK_MINUS TOK_MULT TOK_DIV TOK_MOD TOK_COMPL TOK_COLON TOK_EQTILDE
- TOK_RP TOK_LP
+ TOK_RP TOK_LP TOK_TILDETILDE
%%
@@ -478,6 +477,10 @@ expr:
DESTROY($4);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
+ | expr TOK_TILDETILDE expr { $$ = op_tildetilde ($1, $3);
+ DESTROY($2);
+ @$.first_column = @1.first_column; @$.last_column = @3.last_column;
+ @$.first_line=0; @$.last_line=0;}
;
%%
@@ -1617,3 +1620,29 @@ op_eqtilde (struct val *a, struct val *b)
return v;
}
+
+static struct val * /* this is a string concat operator */
+op_tildetilde (struct val *a, struct val *b)
+{
+ struct val *v;
+ char *vs;
+
+ /* coerce to both arguments to strings */
+ to_string(a);
+ to_string(b);
+ /* strip double quotes from both -- */
+ strip_quotes(a);
+ strip_quotes(b);
+
+ vs = malloc(strlen(a->u.s)+strlen(b->u.s)+1);
+ strcpy(vs,a->u.s);
+ strcat(vs,b->u.s);
+
+ v = make_str(vs);
+
+ /* free arguments */
+ free_value(a);
+ free_value(b);
+
+ return v;
+}