[antlr-interest] Java string array issue in v3.
Gavin Lambert
antlr at mirality.co.nz
Sat Jun 16 14:48:23 PDT 2007
At 06:38 17/06/2007, Kay Roepke wrote:
>FYI, the above URL has a comment describing the fix. When (and
if)
>that goes through, you will be able to escape '[' and ']'
>characters in rule arguments, thus allowing things like String[]
>strArray as parameters.
Why can't it be implemented like it was in v2, which didn't
require any escaping at all?
IIRC it maintained a count of opened square brackets, so the
sequence:
start[HashMap fieldMap, String[] fqls]
would be interpreted something like this:
- rulename 'start'
- open parameter block '[' (incrementing "number of square
brackets" to one)
- parameter 1 type 'HashMap'
- parameter 1 name 'fieldMap'
- parameter separator ','
- parameter 2 type 'String[]' (incrementing then decrementing
its internal "number of square brackets" counter to avoid exiting
the parameter block)
- parameter 2 name 'fqls'
- end of parameter list ']' (close square bracket encountered
when "number of square brackets" was one)
I guess escaping is more robust in pathological cases (where the
target language requires unbalanced square brackets), but I can't
think of any common language where that is the case, so I don't
think it's worth worrying about. Escaping should probably be
supported regardless (as a matter of course), but my point is that
it shouldn't be *required* in this case. Escaping is unnatural.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070617/72afaecc/attachment.html
More information about the antlr-interest
mailing list