diff options
Diffstat (limited to 'src/format/mangling')
-rw-r--r-- | src/format/mangling/itanium_gram.y | 77 | ||||
-rw-r--r-- | src/format/mangling/itanium_tok.l | 49 |
2 files changed, 120 insertions, 6 deletions
diff --git a/src/format/mangling/itanium_gram.y b/src/format/mangling/itanium_gram.y index 4fa7bcb..da1ea10 100644 --- a/src/format/mangling/itanium_gram.y +++ b/src/format/mangling/itanium_gram.y @@ -122,6 +122,15 @@ char *strmerge(char *str1, const char *sep, char *str2); %token ST SA SB SS SI SO SD +%token OPER_NEW OPER_NEW_ARRAY OPER_DELETE OPER_DELETE_ARRAY OPER_PLUS_UNARY OPER_NEG_UNARY +%token OPER_AND_UNARY OPER_DE_UNARY OPER_COMPL OPER_PLUS OPER_MINUS OPER_MUL OPER_DIV OPER_MOD +%token OPER_AND OPER_OR OPER_EXCL_OR OPER_AS OPER_PLUS_EQ OPER_MINUS_EQ OPER_MUL_EQ OPER_DIV_EQ +%token OPER_MOD_EQ OPER_AND_EQ OPER_OR_EQ OPER_EXCL_OR_EQ OPER_LEFT_SHIFT OPER_RIGHT_SHIFT +%token OPER_LEFT_SHIFT_EQ OPER_RIGHT_SHIFT_EQ OPER_EQUAL OPER_NOT_EQ OPER_LESS OPER_GREATER +%token OPER_LESS_EQ OPER_GREATER_EQ OPER_NOT OPER_AND_AND OPER_OR_OR OPER_PLUS_PLUS OPER_MINUS_MINUS +%token OPER_COMMA OPER_PRIV_MEMB OPER_POINTER_TO OPER_CLASS OPER_INDEX + + %token NUMBER CHAR @@ -155,7 +164,7 @@ char *strmerge(char *str1, const char *sep, char *str2); %type <text> name unscoped_name unscoped_template_name nested_name -%type <text> unqualified_name +%type <text> unqualified_name operator_name %type <text> prefix source_name @@ -208,7 +217,7 @@ encoding: name: nested_name { $$ = $1; g_binary_routine_set_name(routine, $1); } - | unscoped_name { $$ = $1; /*g_binary_routine_set_name(routine, $1);*/ } + | unscoped_name { $$ = $1; g_binary_routine_set_name(routine, $1); } | unscoped_template_name template_args { $$ = stradd($1, $2); /* TODO : merge -> free */ } ; @@ -231,15 +240,17 @@ nested_name: prefix: - /* vide */ { $$ = NULL; } + /* vide */ { $$ = NULL; printf("passage E\n"); } | prefix unqualified_name { $$ = ($2 != NULL ? strmerge($1, "::", $2) : $1); } + | substitution { $$ = $1; } ; unqualified_name: - ctor_dtor_name { $$ = NULL; } + operator_name { printf("dup :: '%s'\n", $1); fflush(NULL) ;$$ = strdup($1) ; } + | ctor_dtor_name { printf("passage C\n"); $$ = NULL; } | source_name { $$ = $1; } ; @@ -255,6 +266,60 @@ identifier: | CHAR { build_itanium_identifier(demangler, $1); } ; +operator_name: + OPER_NEW { $$ = "new"; } + | OPER_NEW_ARRAY { $$ = "new[]"; } + | OPER_DELETE { $$ = "delete"; } + | OPER_DELETE_ARRAY { $$ = "delete[]"; } + | OPER_PLUS_UNARY { $$ = "+"; } + | OPER_NEG_UNARY { $$ = "-"; } + | OPER_AND_UNARY { $$ = "&"; } + | OPER_DE_UNARY { $$ = "*"; } + | OPER_COMPL { $$ = "~"; } + | OPER_PLUS { $$ = "+"; } + | OPER_MINUS { $$ = "-"; } + | OPER_MUL { $$ = "*"; } + | OPER_DIV { $$ = "/"; } + | OPER_MOD { $$ = "%"; } + | OPER_AND { $$ = "&"; } + | OPER_OR { $$ = "|"; } + | OPER_EXCL_OR { $$ = "^"; } + | OPER_AS { $$ = "="; } + | OPER_PLUS_EQ { $$ = "+="; } + | OPER_MINUS_EQ { $$ = "-="; } + | OPER_MUL_EQ { $$ = "*="; } + | OPER_DIV_EQ { $$ = "/="; } + | OPER_MOD_EQ { $$ = "%)"; } + | OPER_AND_EQ { $$ = "&="; } + | OPER_OR_EQ { $$ = "|="; } + | OPER_EXCL_OR_EQ { $$ = "^="; } + | OPER_LEFT_SHIFT { $$ = "<<"; } + | OPER_RIGHT_SHIFT { $$ = ">>"; } + | OPER_LEFT_SHIFT_EQ { $$ = "<<="; } + | OPER_RIGHT_SHIFT_EQ { $$ = ">>="; } + | OPER_EQUAL { $$ = "=="; } + | OPER_NOT_EQ { $$ = "!="; } + | OPER_LESS { $$ = "<"; } + | OPER_GREATER { $$ = ">"; } + | OPER_LESS_EQ { $$ = "<="; } + | OPER_GREATER_EQ { $$ = ">="; } + | OPER_NOT { $$ = "!"; } + | OPER_AND_AND { $$ = "&&"; } + | OPER_OR_OR { $$ = "||"; } + | OPER_PLUS_PLUS { $$ = "++"; } + | OPER_MINUS_MINUS { $$ = "--"; } + | OPER_COMMA { $$ = ","; } + | OPER_PRIV_MEMB { $$ = "->*"; } + | OPER_POINTER_TO { $$ = "->"; } + | OPER_CLASS { $$ = "()"; } + | OPER_INDEX { $$ = "[]"; } + ; + + + + + + ctor_dtor_name: C1 { g_binary_routine_set_type(routine, RTT_CONSTRUCTOR); } | C2 { g_binary_routine_set_type(routine, RTT_CONSTRUCTOR); } @@ -331,7 +396,7 @@ class_enum_type: template_args: - II template_arg_list EE { $$ = stradd(strprep($2, "<"), ">"); } + II template_arg_list EE { printf("passage I\n"); $$ = stradd(strprep($2, "<"), ">"); } ; template_arg_list: @@ -344,7 +409,7 @@ template_arg: ; substitution: - ST { $$ = strdup("std::"); } + ST { $$ = strdup("std"); } | SA { $$ = strdup("std::allocator"); } | SB { $$ = strdup("std::basic_string"); } | SS { $$ = strdup("std::string"); } diff --git a/src/format/mangling/itanium_tok.l b/src/format/mangling/itanium_tok.l index 5eef799..bc5f5f1 100644 --- a/src/format/mangling/itanium_tok.l +++ b/src/format/mangling/itanium_tok.l @@ -85,6 +85,55 @@ So { return SO; } Sd { return SD; } +nw { return OPER_NEW; } +na { return OPER_NEW_ARRAY; } +dl { return OPER_DELETE; } +da { return OPER_DELETE_ARRAY; } +ps { return OPER_PLUS_UNARY; } +ng { return OPER_NEG_UNARY; } +ad { return OPER_AND_UNARY; } +de { return OPER_DE_UNARY; } +co { return OPER_COMPL; } +pl { return OPER_PLUS; } +mi { return OPER_MINUS; } +ml { return OPER_MUL; } +dv { return OPER_DIV; } +rm { return OPER_MOD; } +an { return OPER_AND; } +or { return OPER_OR; } +eo { return OPER_EXCL_OR; } +aS { return OPER_AS; } +pL { return OPER_PLUS_EQ; } +mI { return OPER_MINUS_EQ; } +mL { return OPER_MUL_EQ; } +dV { return OPER_DIV_EQ; } +rM { return OPER_MOD_EQ; } +aN { return OPER_AND_EQ; } +oR { return OPER_OR_EQ; } +eO { return OPER_EXCL_OR_EQ; } +ls { return OPER_LEFT_SHIFT; } +rs { return OPER_RIGHT_SHIFT; } +lS { return OPER_LEFT_SHIFT_EQ; } +rS { return OPER_RIGHT_SHIFT_EQ; } +eq { return OPER_EQUAL; } +ne { return OPER_NOT_EQ; } +lt { return OPER_LESS; } +gt { return OPER_GREATER; } +le { return OPER_LESS_EQ; } +ge { return OPER_GREATER_EQ; } +nt { return OPER_NOT; } +aa { return OPER_AND_AND; } +oo { return OPER_OR_OR; } +pp { return OPER_PLUS_PLUS; } +mm { return OPER_MINUS_MINUS; } +cm { return OPER_COMMA; } +pm { return OPER_PRIV_MEMB; } +pt { return OPER_POINTER_TO; } +cl { return OPER_CLASS; } +ix { return OPER_INDEX; } + + + [0-9]+ { yylval.val = atoi(yytext); return NUMBER; } <identifier>. { if (--itanium_txt_length == 0) BEGIN(INITIAL); yylval.car = *yytext; return CHAR; } |