Your change modifies the NAME token whereever it is used, for instance
when delcaring the name of a function:

    rule Declaration:
...
      | "function" NAME OptFP OptString ";"       {{ function(NAME, OptFP, 
OptString) }}

Even in a 'variable' declaration, it allows things that don't make
sense, like
    variable will_not_work*;
or
    variable *9;
or even
    variable ****;

Does the alternative below work for you?

-- 8< --
>From c3c02ff27c39cd62fe4b90ab0e103bcbd6477aea Mon Sep 17 00:00:00 2001
From: Jeff Epler <[email protected]>
Date: Mon, 25 Apr 2011 04:24:38 -0500

The comp 'variable' declaration is much less powerful than a variable
declaration in plain C.  This change lifts one specific limitation:
it is now possible to declare pointers by making the initial character
of the variable name a star:
    variable int *example;

Note that the following alternatives are still not acceptable, because
the * is not part of the variable name:
    variable int* example;
    variable int * example;
---
 src/hal/utils/comp.g |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/hal/utils/comp.g b/src/hal/utils/comp.g
index 7146dc7..db17546 100644
--- a/src/hal/utils/comp.g
+++ b/src/hal/utils/comp.g
@@ -31,6 +31,7 @@ parser Hal:
     token PINDIRECTION: "in|out|io"
     token TYPE: "float|bit|signed|unsigned|u32|s32"
     token NAME: "[a-zA-Z_][a-zA-Z0-9_]*"
+    token STARREDNAME: "[*]*[a-zA-Z_][a-zA-Z0-9_]*"
     token HALNAME: "[#a-zA-Z_][-#a-zA-Z0-9_.]*"
     token FPNUMBER: "-?([0-9]*\.[0-9]+|[0-9]+\.?)([Ee][+-]?[0-9]+)?f?"
     token NUMBER: "0x[0-9a-fA-F]+|[+-]?[0-9]+"
@@ -46,7 +47,7 @@ parser Hal:
         "pin" PINDIRECTION TYPE HALNAME OptArray OptSAssign OptPersonality 
OptString ";"  {{ pin(HALNAME, TYPE, OptArray, PINDIRECTION, OptString, 
OptSAssign, OptPersonality) }}
       | "param" PARAMDIRECTION TYPE HALNAME OptArray OptSAssign OptPersonality 
OptString ";" {{ param(HALNAME, TYPE, OptArray, PARAMDIRECTION, OptString, 
OptSAssign, OptPersonality) }}
       | "function" NAME OptFP OptString ";"       {{ function(NAME, OptFP, 
OptString) }}
-      | "variable" NAME {{ NAME1=NAME; }} NAME OptSimpleArray OptAssign ";" {{ 
variable(NAME1, NAME, OptSimpleArray, OptAssign) }}
+      | "variable" NAME STARREDNAME OptSimpleArray OptAssign ";" {{ 
variable(NAME, STARREDNAME, OptSimpleArray, OptAssign) }}
       | "option" NAME OptValue ";"   {{ option(NAME, OptValue) }}
       | "see_also" String ";"   {{ see_also(String) }}
       | "notes" String ";"   {{ notes(String) }}
@@ -587,6 +588,7 @@ static int comp_id;
                 print >>f, "#define %s (inst->%s)" % (to_c(name), to_c(name))
 
         for type, name, array, value in variables:
+            name = name.replace("*", "")
             print >>f, "#undef %s" % name
             print >>f, "#define %s (inst->%s)" % (name, name)
 
-- 
1.7.2.5

------------------------------------------------------------------------------
Fulfilling the Lean Software Promise
Lean software platforms are now widely adopted and the benefits have been 
demonstrated beyond question. Learn why your peers are replacing JEE 
containers with lightweight application servers - and what you can gain 
from the move. http://p.sf.net/sfu/vmware-sfemails
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to