fixes #1006
This commit is contained in:
parent
5f64d7a353
commit
b76d2eac7f
3 changed files with 14 additions and 8 deletions
|
|
@ -1279,7 +1279,8 @@ proc leftBindingPower(p : var TParser, tok : ref TToken) : int =
|
||||||
of pxComma:
|
of pxComma:
|
||||||
return 10
|
return 10
|
||||||
# throw == 20
|
# throw == 20
|
||||||
of pxAsgn, pxPlusAsgn, pxMinusAsgn, pxStarAsgn, pxSlashAsgn, pxModAsgn, pxShlAsgn, pxShrAsgn, pxAmpAsgn, pxHatAsgn, pxBarAsgn:
|
of pxAsgn, pxPlusAsgn, pxMinusAsgn, pxStarAsgn, pxSlashAsgn, pxModAsgn,
|
||||||
|
pxShlAsgn, pxShrAsgn, pxAmpAsgn, pxHatAsgn, pxBarAsgn:
|
||||||
return 30
|
return 30
|
||||||
of pxConditional:
|
of pxConditional:
|
||||||
return 40
|
return 40
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,8 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
let luf = if withinMixin notin flags: {checkUndeclared} else: {}
|
let luf = if withinMixin notin flags: {checkUndeclared} else: {}
|
||||||
var s = qualifiedLookUp(c, n, luf)
|
var s = qualifiedLookUp(c, n, luf)
|
||||||
if s != nil: result = semGenericStmtSymbol(c, n, s)
|
if s != nil: result = semGenericStmtSymbol(c, n, s)
|
||||||
|
else:
|
||||||
|
|
||||||
# XXX for example: ``result.add`` -- ``add`` needs to be looked up here...
|
# XXX for example: ``result.add`` -- ``add`` needs to be looked up here...
|
||||||
of nkEmpty, nkSym..nkNilLit:
|
of nkEmpty, nkSym..nkNilLit:
|
||||||
# see tests/compile/tgensymgeneric.nim:
|
# see tests/compile/tgensymgeneric.nim:
|
||||||
|
|
|
||||||
|
|
@ -499,18 +499,21 @@ other binary operators are left-associative.
|
||||||
Precedence
|
Precedence
|
||||||
----------
|
----------
|
||||||
|
|
||||||
For operators that are not keywords the precedence is determined by the
|
Unary operators always bind stronger than any binary
|
||||||
|
operator: ``$a + b`` is ``($a) + b`` and not ``$(a + b)``.
|
||||||
|
|
||||||
|
If an unary operator's relevant character is ``@`` it is a `sigil-like`:idx:
|
||||||
|
operator which binds stronger than a ``primarySuffix``: ``@x.abc`` is parsed
|
||||||
|
as ``(@x).abc`` whereas ``$x.abc`` is parsed as ``$(x.abc)``.
|
||||||
|
|
||||||
|
|
||||||
|
For binary operators that are not keywords the precedence is determined by the
|
||||||
following rules:
|
following rules:
|
||||||
|
|
||||||
If the operator ends with ``=`` and its relevant character is none of
|
If the operator ends with ``=`` and its relevant character is none of
|
||||||
``<``, ``>``, ``!``, ``=``, ``~``, ``?``, it is an *assignment operator* which
|
``<``, ``>``, ``!``, ``=``, ``~``, ``?``, it is an *assignment operator* which
|
||||||
has the lowest precedence.
|
has the lowest precedence.
|
||||||
|
|
||||||
If the operator's relevant character is ``@`` it is a `sigil-like`:idx:
|
|
||||||
operator which binds stronger than a ``primarySuffix``: ``@x.abc`` is parsed
|
|
||||||
as ``(@x).abc`` whereas ``$x.abc`` is parsed as ``$(x.abc)``.
|
|
||||||
|
|
||||||
|
|
||||||
Otherwise precedence is determined by the relevant character.
|
Otherwise precedence is determined by the relevant character.
|
||||||
|
|
||||||
================ =============================================== ================== ===============
|
================ =============================================== ================== ===============
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue