1. I notice that Nim's grammar has this rule:
castExpr = 'cast' ('[' optInd typeDesc optPar ']' '(' optInd expr optPar ')') /
An ordered choice followed by nothing, can anyone tell me what this means?
Thanks a lot!
Q1 is solved, I scan through nim's compiler/parser.nim and found these comments:
#| castExpr = 'cast' ('[' optInd typeDesc optPar ']' '(' optInd expr optPar ')') /
# ('(' optInd exprColonEqExpr optPar ')')
Thus this should be a typo. I found another problem:
#| literal = | INT_LIT | INT8_LIT | INT16_LIT | INT32_LIT | INT64_LIT
#| | UINT_LIT | UINT8_LIT | UINT16_LIT | UINT32_LIT | UINT64_LIT
#| | FLOAT_LIT | FLOAT32_LIT | FLOAT64_LIT
#| | STR_LIT | RSTR_LIT | TRIPLESTR_LIT
#| | CHAR_LIT | CUSTOM_NUMERIC_LIT
#| | NIL
There seems to be an extra "|" in the front of literal's derivation because they can't be nil. BTW, I think it's better if you could clarify the precedence of operators in the manual, I see this:
tupleDecl = 'tuple'
'[' optInd (identColonEquals (comma/semicolon)?)* optPar ']' |
COMMENT? (IND{>} identColonEquals (IND{=} identColonEquals)*)?
which obviously, means:
tupleDecl = 'tuple' (
'[' optInd (identColonEquals (comma/semicolon)?)* optPar ']' |
COMMENT? (IND{>} identColonEquals (IND{=} identColonEquals)*)? )
But you didn't clarify how indent should work..