mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
language change: 'generic' and 'atomic' are not keywords anymore
This commit is contained in:
@@ -33,13 +33,13 @@ type
|
||||
TTokType* = enum
|
||||
tkInvalid, tkEof, # order is important here!
|
||||
tkSymbol, # keywords:
|
||||
tkAddr, tkAnd, tkAs, tkAsm, tkAtomic,
|
||||
tkAddr, tkAnd, tkAs, tkAsm,
|
||||
tkBind, tkBlock, tkBreak, tkCase, tkCast,
|
||||
tkConcept, tkConst, tkContinue, tkConverter,
|
||||
tkDefer, tkDiscard, tkDistinct, tkDiv, tkDo,
|
||||
tkElif, tkElse, tkEnd, tkEnum, tkExcept, tkExport,
|
||||
tkFinally, tkFor, tkFrom, tkFunc,
|
||||
tkGeneric, tkIf, tkImport, tkIn, tkInclude, tkInterface,
|
||||
tkIf, tkImport, tkIn, tkInclude, tkInterface,
|
||||
tkIs, tkIsnot, tkIterator,
|
||||
tkLet,
|
||||
tkMacro, tkMethod, tkMixin, tkMod, tkNil, tkNot, tkNotin,
|
||||
@@ -75,12 +75,12 @@ const
|
||||
tokKeywordHigh* = pred(tkIntLit)
|
||||
TokTypeToStr*: array[TTokType, string] = ["tkInvalid", "[EOF]",
|
||||
"tkSymbol",
|
||||
"addr", "and", "as", "asm", "atomic",
|
||||
"addr", "and", "as", "asm",
|
||||
"bind", "block", "break", "case", "cast",
|
||||
"concept", "const", "continue", "converter",
|
||||
"defer", "discard", "distinct", "div", "do",
|
||||
"elif", "else", "end", "enum", "except", "export",
|
||||
"finally", "for", "from", "func", "generic", "if",
|
||||
"finally", "for", "from", "func", "if",
|
||||
"import", "in", "include", "interface", "is", "isnot", "iterator",
|
||||
"let",
|
||||
"macro", "method", "mixin", "mod",
|
||||
|
||||
@@ -1140,13 +1140,9 @@ proc primary(p: var TParser, mode: TPrimaryMode): PNode =
|
||||
else:
|
||||
result = newNodeP(nkObjectTy, p)
|
||||
getTok(p)
|
||||
of tkGeneric, tkConcept:
|
||||
of tkConcept:
|
||||
if mode == pmTypeDef:
|
||||
let wasGeneric = p.tok.tokType == tkGeneric
|
||||
result = parseTypeClass(p)
|
||||
# hack so that it's remembered and can be marked as deprecated in
|
||||
# sem'check:
|
||||
if wasGeneric: result.flags.incl nfBase2
|
||||
else:
|
||||
parMessage(p, errInvalidToken, p.tok)
|
||||
of tkStatic:
|
||||
|
||||
@@ -1218,8 +1218,6 @@ template modifierTypeKindOfNode(n: PNode): TTypeKind =
|
||||
|
||||
proc semTypeClass(c: PContext, n: PNode, prev: PType): PType =
|
||||
# if n.sonsLen == 0: return newConstraint(c, tyTypeClass)
|
||||
if nfBase2 in n.flags:
|
||||
message(n.info, warnDeprecated, "use 'concept' instead; 'generic'")
|
||||
let
|
||||
pragmas = n[1]
|
||||
inherited = n[2]
|
||||
|
||||
@@ -21,11 +21,11 @@ type
|
||||
TSpecialWord* = enum
|
||||
wInvalid,
|
||||
|
||||
wAddr, wAnd, wAs, wAsm, wAtomic,
|
||||
wAddr, wAnd, wAs, wAsm,
|
||||
wBind, wBlock, wBreak, wCase, wCast, wConcept, wConst,
|
||||
wContinue, wConverter, wDefer, wDiscard, wDistinct, wDiv, wDo,
|
||||
wElif, wElse, wEnd, wEnum, wExcept, wExport,
|
||||
wFinally, wFor, wFrom, wFunc, wGeneric, wIf, wImport, wIn,
|
||||
wFinally, wFor, wFrom, wFunc, wIf, wImport, wIn,
|
||||
wInclude, wInterface, wIs, wIsnot, wIterator, wLet,
|
||||
wMacro, wMethod, wMixin, wMod, wNil,
|
||||
wNot, wNotin, wObject, wOf, wOr, wOut, wProc, wPtr, wRaise, wRef, wReturn,
|
||||
@@ -103,12 +103,12 @@ const
|
||||
|
||||
specialWords*: array[low(TSpecialWord)..high(TSpecialWord), string] = ["",
|
||||
|
||||
"addr", "and", "as", "asm", "atomic",
|
||||
"addr", "and", "as", "asm",
|
||||
"bind", "block", "break", "case", "cast",
|
||||
"concept", "const", "continue", "converter",
|
||||
"defer", "discard", "distinct", "div", "do",
|
||||
"elif", "else", "end", "enum", "except", "export",
|
||||
"finally", "for", "from", "func", "generic", "if",
|
||||
"finally", "for", "from", "func", "if",
|
||||
"import", "in", "include", "interface", "is", "isnot", "iterator",
|
||||
"let",
|
||||
"macro", "method", "mixin", "mod", "nil", "not", "notin",
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
addr and as asm atomic
|
||||
addr and as asm
|
||||
bind block break
|
||||
case cast concept const continue converter
|
||||
defer discard distinct div do
|
||||
elif else end enum except export
|
||||
finally for from func
|
||||
generic
|
||||
if import in include interface is isnot iterator
|
||||
let
|
||||
macro method mixin mod
|
||||
|
||||
@@ -49,12 +49,12 @@ const
|
||||
|
||||
# The following list comes from doc/keywords.txt, make sure it is
|
||||
# synchronized with this array by running the module itself as a test case.
|
||||
nimKeywords = ["addr", "and", "as", "asm", "atomic", "bind", "block",
|
||||
nimKeywords = ["addr", "and", "as", "asm", "bind", "block",
|
||||
"break", "case", "cast", "concept", "const", "continue", "converter",
|
||||
"defer", "discard", "distinct", "div", "do",
|
||||
"elif", "else", "end", "enum", "except", "export",
|
||||
"finally", "for", "from", "func",
|
||||
"generic", "if", "import", "in", "include",
|
||||
"if", "import", "in", "include",
|
||||
"interface", "is", "isnot", "iterator", "let", "macro", "method",
|
||||
"mixin", "mod", "nil", "not", "notin", "object", "of", "or", "out", "proc",
|
||||
"ptr", "raise", "ref", "return", "shl", "shr", "static",
|
||||
@@ -901,12 +901,11 @@ when isMainModule:
|
||||
for filename in ["doc/keywords.txt", "../../../doc/keywords.txt"]:
|
||||
try:
|
||||
let input = string(readFile(filename))
|
||||
keywords = input.split()
|
||||
keywords = input.splitWhitespace()
|
||||
break
|
||||
except:
|
||||
echo filename, " not found"
|
||||
doAssert(not keywords.isNil, "Couldn't read any keywords.txt file!")
|
||||
doAssert keywords.len == nimKeywords.len, "No matching lengths"
|
||||
for i in 0..keywords.len-1:
|
||||
#echo keywords[i], " == ", nimKeywords[i]
|
||||
for i in 0..min(keywords.len, nimKeywords.len)-1:
|
||||
doAssert keywords[i] == nimKeywords[i], "Unexpected keyword"
|
||||
doAssert keywords.len == nimKeywords.len, "No matching lengths"
|
||||
|
||||
@@ -4,8 +4,8 @@ discard """
|
||||
|
||||
type
|
||||
TFooContainer[T] = object
|
||||
|
||||
TContainer[T] = generic var c
|
||||
|
||||
TContainer[T] = concept var c
|
||||
foo(c, T)
|
||||
|
||||
proc foo[T](c: var TFooContainer[T], val: T) =
|
||||
|
||||
Reference in New Issue
Block a user