Last active
August 29, 2015 14:21
-
-
Save besquared/11751660c97962d2ee55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Match [ [1,2,3], [4,5,6], ... ] | |
class Matrix | |
constructor(@rows) -> null | |
Matrix: [ | |
o 'LEFT_BRACKET (MatrixRow)+ RIGHT_BRACKET', -> | |
new Matrix($2) | |
] | |
MatrixRow: [ | |
o 'COMMA MatrixRow', -> $2 | |
o 'LEFT_BRACKET (MatrixRowItem)+ RIGHT_BRACKET', -> $2 | |
] | |
MatrixRowElement: [ | |
o 'NUMBER', -> $1 | |
o 'COMMA NUMBER', -> $2 | |
] |
Note that matrices like [, , , , , [, 2, 3] ]
are also matched, which might or might not be desired.
This alternative approach might help.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess technically you could simplify the matrix rule to 'LEFT_BRACKET (MatrixRow)+ RIGHT_BRACKET'