miguel01997 / cookcc

Automatically exported from code.google.com/p/cookcc
Other
0 stars 1 forks source link

Improve documentation of Java parser #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm referring to
http://code.google.com/p/cookcc/wiki/JavaParserInput#Case_2:_Function_returns_vo
id

I suggest to add an extra section to explain args:

`args` is a list of indexes (separated by space) of the elements of `rhs`
which the method expects as arguments. For example:

        @Rule (lhs = "stmt", rhs = "VARIABLE ASSIGN expr SEMICOLON", args =
"1 3")
        protected Node parseAssign (String var, Node expr)
        {
                return new AssignNode (var, expr);
        }

This will assign the result of tokenizing `VARIABLE` to `String var` and
the result of parsing `expr` to the method parameter `Node expr`.

Note that the indexes need not be in any specific order. This would be
equivalent (indexes and method parameters swapped):

        @Rule (lhs = "stmt", rhs = "VARIABLE ASSIGN expr SEMICOLON", args =
"3 1")
        protected Node parseAssign (Node expr, String var)
        {
                return new AssignNode (var, expr);
        }

Original issue reported on code.google.com by adigu...@gmail.com on 1 Dec 2008 at 9:54

GoogleCodeExporter commented 9 years ago
I added your text as a separate section.

Original comment by superdup...@gmail.com on 1 Dec 2008 at 11:52