Monday, 20 September 2010

FsYacc: Parsing Variable-Length Lists, Part 2

Without writing any special F# code, and only relying on the parser, the results of the previous post can be achieved by making this change.

/*
PFunctionArgs:
    | PExpression                       { $1 }
    | PExpression COMMA PFunctionArgs   { ListExpression($1::[$3])  }
*/

PFunctionArgs:
    | PExpression                       { $1 }
    | PExpression COMMA PFunctionArgList   { ListExpression($1::$3)  }

PFunctionArgList:
    | PExpression                           { [$1] }
    | PExpression COMMA PFunctionArgList    { $1::$3  }
Of course, there are no interesting F# code samples to be had.

No comments:

Post a Comment