[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PHP variables in actions
From: |
Tim Landscheidt |
Subject: |
PHP variables in actions |
Date: |
Fri, 20 Jan 2012 04:26:41 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
I wrote quite some "few days" ago:
> [...]
> I would strongly disagree with your assumption that Bison
> isn't ready for this, though. The code at
> <URI:https://github.com/scfc/bison-php> is already working
> for simple examples. The only real showstopper yet - on the
> C side - is the use of "$variables" in actions for which I
> have written a patch that I will post for discussion in the
> next few days (which reminds that I still have to reply to
> Bruno on bug-gnulib :-().
I'd like to ask for some feedback on the attached patch. It
works, but it is rather ugly.
Would it be acceptable in this form, or should I refactor
the surrounding code for example by splitting up the scanner
grammar around handle_action_dollar () into type-name-given/
type-name-not-given + numerical-ref/symbol-ref + with-brack-
ets/without-brackets?
Tim
diff --git a/src/scan-code.l b/src/scan-code.l
index cf4e761..8379c4e 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -510,7 +510,7 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
static long int
parse_ref (char *cp, symbol_list *rule, int rule_length,
int midrule_rhs_index, char *text, location text_loc,
- char dollar_or_at)
+ char dollar_or_at, bool type_name_given)
{
symbol_list *l;
char *cp_end;
@@ -618,6 +618,13 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
cp_end - cp : ref_tail_fields - cp;
unsigned indent = 0;
+ if (!strcmp (language->language, "php") && !explicit_bracketing &&
!type_name_given && dollar_or_at == '$')
+ {
+ ref_tail_fields = NULL;
+ obstack_sgrow (&obstack_for_string, cp - 1);
+ return INVALID_REF;
+ }
+
complain_at_indent (text_loc, &indent, _("invalid reference: %s"),
quote (text));
indent += SUB_INDENT;
@@ -735,7 +742,7 @@ handle_action_dollar (symbol_list *rule, char *text,
location dollar_loc)
}
n = parse_ref (cp, effective_rule, effective_rule_length,
- rule->midrule_parent_rhs_index, text, dollar_loc, '$');
+ rule->midrule_parent_rhs_index, text, dollar_loc, '$',
type_name != NULL);
if (gt_ptr)
*gt_ptr = '\0';
@@ -827,7 +834,7 @@ handle_action_at (symbol_list *rule, char *text, location
at_loc)
muscle_percent_define_ensure("locations", at_loc, true);
n = parse_ref (cp, effective_rule, effective_rule_length,
- rule->midrule_parent_rhs_index, text, at_loc, '@');
+ rule->midrule_parent_rhs_index, text, at_loc, '@',
false);
switch (n)
{
case INVALID_REF:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- PHP variables in actions,
Tim Landscheidt <=