'with' and 'without' are not keywords anymore

This commit is contained in:
Araq 2017-09-30 18:16:09 +02:00
commit 3ccc9c467d
7 changed files with 26 additions and 15 deletions

View file

@ -48,7 +48,7 @@ type
tkShl, tkShr, tkStatic, tkShl, tkShr, tkStatic,
tkTemplate, tkTemplate,
tkTry, tkTuple, tkType, tkUsing, tkTry, tkTuple, tkType, tkUsing,
tkVar, tkWhen, tkWhile, tkWith, tkWithout, tkXor, tkVar, tkWhen, tkWhile, tkXor,
tkYield, # end of keywords tkYield, # end of keywords
tkIntLit, tkInt8Lit, tkInt16Lit, tkInt32Lit, tkInt64Lit, tkIntLit, tkInt8Lit, tkInt16Lit, tkInt32Lit, tkInt64Lit,
tkUIntLit, tkUInt8Lit, tkUInt16Lit, tkUInt32Lit, tkUInt64Lit, tkUIntLit, tkUInt8Lit, tkUInt16Lit, tkUInt32Lit, tkUInt64Lit,
@ -89,7 +89,7 @@ const
"shl", "shr", "static", "shl", "shr", "static",
"template", "template",
"try", "tuple", "type", "using", "try", "tuple", "type", "using",
"var", "when", "while", "with", "without", "xor", "var", "when", "while", "xor",
"yield", "yield",
"tkIntLit", "tkInt8Lit", "tkInt16Lit", "tkInt32Lit", "tkInt64Lit", "tkIntLit", "tkInt8Lit", "tkInt16Lit", "tkInt32Lit", "tkInt64Lit",
"tkUIntLit", "tkUInt8Lit", "tkUInt16Lit", "tkUInt32Lit", "tkUInt64Lit", "tkUIntLit", "tkUInt8Lit", "tkUInt16Lit", "tkUInt32Lit", "tkUInt64Lit",

View file

@ -1038,9 +1038,15 @@ proc parseTypeDescKAux(p: var TParser, kind: TNodeKind,
optInd(p, result) optInd(p, result)
if not isOperator(p.tok) and isExprStart(p): if not isOperator(p.tok) and isExprStart(p):
addSon(result, primary(p, mode)) addSon(result, primary(p, mode))
if kind == nkDistinctTy and p.tok.tokType in {tkWith, tkWithout}: if kind == nkDistinctTy and p.tok.tokType == tkSymbol:
let nodeKind = if p.tok.tokType == tkWith: nkWith # XXX document this feature!
else: nkWithout var nodeKind: TNodeKind
if p.tok.ident.s == "with":
nodeKind = nkWith
elif p.tok.ident.s == "without":
nodeKind = nkWithout
else:
return result
getTok(p) getTok(p)
let list = newNodeP(nodeKind, p) let list = newNodeP(nodeKind, p)
result.addSon list result.addSon list

View file

@ -906,9 +906,14 @@ proc parseTypeDescKAux(p: var TParser, kind: TNodeKind,
optInd(p, result) optInd(p, result)
if not isOperator(p.tok) and isExprStart(p): if not isOperator(p.tok) and isExprStart(p):
addSon(result, primary(p, mode)) addSon(result, primary(p, mode))
if kind == nkDistinctTy and p.tok.tokType in {tkWith, tkWithout}: if kind == nkDistinctTy and p.tok.tokType == tkSymbol:
let nodeKind = if p.tok.tokType == tkWith: nkWith var nodeKind: TNodeKind
else: nkWithout if p.tok.ident.s == "with":
nodeKind = nkWith
elif p.tok.ident.s == "without":
nodeKind = nkWithout
else:
return result
getTok(p) getTok(p)
let list = newNodeP(nodeKind, p) let list = newNodeP(nodeKind, p)
result.addSon list result.addSon list

View file

@ -1079,9 +1079,9 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
gsub(g, n.sons[0]) gsub(g, n.sons[0])
if n.len > 1: if n.len > 1:
if n[1].kind == nkWith: if n[1].kind == nkWith:
putWithSpace(g, tkWith, " with") putWithSpace(g, tkSymbol, " with")
else: else:
putWithSpace(g, tkWithout, " without") putWithSpace(g, tkSymbol, " without")
gcomma(g, n[1]) gcomma(g, n[1])
else: else:
put(g, tkDistinct, "distinct") put(g, tkDistinct, "distinct")

View file

@ -30,7 +30,7 @@ type
wMacro, wMethod, wMixin, wMod, wNil, wMacro, wMethod, wMixin, wMod, wNil,
wNot, wNotin, wObject, wOf, wOr, wOut, wProc, wPtr, wRaise, wRef, wReturn, wNot, wNotin, wObject, wOf, wOr, wOut, wProc, wPtr, wRaise, wRef, wReturn,
wShl, wShr, wStatic, wTemplate, wTry, wTuple, wType, wUsing, wVar, wShl, wShr, wStatic, wTemplate, wTry, wTuple, wType, wUsing, wVar,
wWhen, wWhile, wWith, wWithout, wXor, wYield, wWhen, wWhile, wXor, wYield,
wColon, wColonColon, wEquals, wDot, wDotDot, wColon, wColonColon, wEquals, wDot, wDotDot,
wStar, wMinus, wStar, wMinus,
@ -116,7 +116,7 @@ const
"out", "proc", "ptr", "raise", "ref", "return", "out", "proc", "ptr", "raise", "ref", "return",
"shl", "shr", "static", "shl", "shr", "static",
"template", "try", "tuple", "type", "using", "var", "template", "try", "tuple", "type", "using", "var",
"when", "while", "with", "without", "xor", "when", "while", "xor",
"yield", "yield",
":", "::", "=", ".", "..", ":", "::", "=", ".", "..",

View file

@ -16,6 +16,6 @@ shl shr static
template try tuple type template try tuple type
using using
var var
when while with without when while
xor xor
yield yield

View file

@ -58,8 +58,8 @@ const
"interface", "is", "isnot", "iterator", "let", "macro", "method", "interface", "is", "isnot", "iterator", "let", "macro", "method",
"mixin", "mod", "nil", "not", "notin", "object", "of", "or", "out", "proc", "mixin", "mod", "nil", "not", "notin", "object", "of", "or", "out", "proc",
"ptr", "raise", "ref", "return", "shl", "shr", "static", "ptr", "raise", "ref", "return", "shl", "shr", "static",
"template", "try", "tuple", "type", "using", "var", "when", "while", "with", "template", "try", "tuple", "type", "using", "var", "when", "while",
"without", "xor", "yield"] "xor", "yield"]
proc getSourceLanguage*(name: string): SourceLanguage = proc getSourceLanguage*(name: string): SourceLanguage =
for i in countup(succ(low(SourceLanguage)), high(SourceLanguage)): for i in countup(succ(low(SourceLanguage)), high(SourceLanguage)):