language change: 'generic' and 'atomic' are not keywords anymore

This commit is contained in:
Andreas Rumpf 2017-11-21 11:27:24 +01:00
commit cae5e33a4a
7 changed files with 17 additions and 25 deletions

View file

@ -33,13 +33,13 @@ type
TTokType* = enum TTokType* = enum
tkInvalid, tkEof, # order is important here! tkInvalid, tkEof, # order is important here!
tkSymbol, # keywords: tkSymbol, # keywords:
tkAddr, tkAnd, tkAs, tkAsm, tkAtomic, tkAddr, tkAnd, tkAs, tkAsm,
tkBind, tkBlock, tkBreak, tkCase, tkCast, tkBind, tkBlock, tkBreak, tkCase, tkCast,
tkConcept, tkConst, tkContinue, tkConverter, tkConcept, tkConst, tkContinue, tkConverter,
tkDefer, tkDiscard, tkDistinct, tkDiv, tkDo, tkDefer, tkDiscard, tkDistinct, tkDiv, tkDo,
tkElif, tkElse, tkEnd, tkEnum, tkExcept, tkExport, tkElif, tkElse, tkEnd, tkEnum, tkExcept, tkExport,
tkFinally, tkFor, tkFrom, tkFunc, tkFinally, tkFor, tkFrom, tkFunc,
tkGeneric, tkIf, tkImport, tkIn, tkInclude, tkInterface, tkIf, tkImport, tkIn, tkInclude, tkInterface,
tkIs, tkIsnot, tkIterator, tkIs, tkIsnot, tkIterator,
tkLet, tkLet,
tkMacro, tkMethod, tkMixin, tkMod, tkNil, tkNot, tkNotin, tkMacro, tkMethod, tkMixin, tkMod, tkNil, tkNot, tkNotin,
@ -75,12 +75,12 @@ const
tokKeywordHigh* = pred(tkIntLit) tokKeywordHigh* = pred(tkIntLit)
TokTypeToStr*: array[TTokType, string] = ["tkInvalid", "[EOF]", TokTypeToStr*: array[TTokType, string] = ["tkInvalid", "[EOF]",
"tkSymbol", "tkSymbol",
"addr", "and", "as", "asm", "atomic", "addr", "and", "as", "asm",
"bind", "block", "break", "case", "cast", "bind", "block", "break", "case", "cast",
"concept", "const", "continue", "converter", "concept", "const", "continue", "converter",
"defer", "discard", "distinct", "div", "do", "defer", "discard", "distinct", "div", "do",
"elif", "else", "end", "enum", "except", "export", "elif", "else", "end", "enum", "except", "export",
"finally", "for", "from", "func", "generic", "if", "finally", "for", "from", "func", "if",
"import", "in", "include", "interface", "is", "isnot", "iterator", "import", "in", "include", "interface", "is", "isnot", "iterator",
"let", "let",
"macro", "method", "mixin", "mod", "macro", "method", "mixin", "mod",

View file

@ -1140,13 +1140,9 @@ proc primary(p: var TParser, mode: TPrimaryMode): PNode =
else: else:
result = newNodeP(nkObjectTy, p) result = newNodeP(nkObjectTy, p)
getTok(p) getTok(p)
of tkGeneric, tkConcept: of tkConcept:
if mode == pmTypeDef: if mode == pmTypeDef:
let wasGeneric = p.tok.tokType == tkGeneric
result = parseTypeClass(p) 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: else:
parMessage(p, errInvalidToken, p.tok) parMessage(p, errInvalidToken, p.tok)
of tkStatic: of tkStatic:

View file

@ -1218,8 +1218,6 @@ template modifierTypeKindOfNode(n: PNode): TTypeKind =
proc semTypeClass(c: PContext, n: PNode, prev: PType): PType = proc semTypeClass(c: PContext, n: PNode, prev: PType): PType =
# if n.sonsLen == 0: return newConstraint(c, tyTypeClass) # if n.sonsLen == 0: return newConstraint(c, tyTypeClass)
if nfBase2 in n.flags:
message(n.info, warnDeprecated, "use 'concept' instead; 'generic'")
let let
pragmas = n[1] pragmas = n[1]
inherited = n[2] inherited = n[2]

View file

@ -21,11 +21,11 @@ type
TSpecialWord* = enum TSpecialWord* = enum
wInvalid, wInvalid,
wAddr, wAnd, wAs, wAsm, wAtomic, wAddr, wAnd, wAs, wAsm,
wBind, wBlock, wBreak, wCase, wCast, wConcept, wConst, wBind, wBlock, wBreak, wCase, wCast, wConcept, wConst,
wContinue, wConverter, wDefer, wDiscard, wDistinct, wDiv, wDo, wContinue, wConverter, wDefer, wDiscard, wDistinct, wDiv, wDo,
wElif, wElse, wEnd, wEnum, wExcept, wExport, 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, wInclude, wInterface, wIs, wIsnot, wIterator, wLet,
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,
@ -103,12 +103,12 @@ const
specialWords*: array[low(TSpecialWord)..high(TSpecialWord), string] = ["", specialWords*: array[low(TSpecialWord)..high(TSpecialWord), string] = ["",
"addr", "and", "as", "asm", "atomic", "addr", "and", "as", "asm",
"bind", "block", "break", "case", "cast", "bind", "block", "break", "case", "cast",
"concept", "const", "continue", "converter", "concept", "const", "continue", "converter",
"defer", "discard", "distinct", "div", "do", "defer", "discard", "distinct", "div", "do",
"elif", "else", "end", "enum", "except", "export", "elif", "else", "end", "enum", "except", "export",
"finally", "for", "from", "func", "generic", "if", "finally", "for", "from", "func", "if",
"import", "in", "include", "interface", "is", "isnot", "iterator", "import", "in", "include", "interface", "is", "isnot", "iterator",
"let", "let",
"macro", "method", "mixin", "mod", "nil", "not", "notin", "macro", "method", "mixin", "mod", "nil", "not", "notin",

View file

@ -1,10 +1,9 @@
addr and as asm atomic addr and as asm
bind block break bind block break
case cast concept const continue converter case cast concept const continue converter
defer discard distinct div do defer discard distinct div do
elif else end enum except export elif else end enum except export
finally for from func finally for from func
generic
if import in include interface is isnot iterator if import in include interface is isnot iterator
let let
macro method mixin mod macro method mixin mod

View file

@ -49,12 +49,12 @@ const
# The following list comes from doc/keywords.txt, make sure it is # 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. # 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", "break", "case", "cast", "concept", "const", "continue", "converter",
"defer", "discard", "distinct", "div", "do", "defer", "discard", "distinct", "div", "do",
"elif", "else", "end", "enum", "except", "export", "elif", "else", "end", "enum", "except", "export",
"finally", "for", "from", "func", "finally", "for", "from", "func",
"generic", "if", "import", "in", "include", "if", "import", "in", "include",
"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",
@ -901,12 +901,11 @@ when isMainModule:
for filename in ["doc/keywords.txt", "../../../doc/keywords.txt"]: for filename in ["doc/keywords.txt", "../../../doc/keywords.txt"]:
try: try:
let input = string(readFile(filename)) let input = string(readFile(filename))
keywords = input.split() keywords = input.splitWhitespace()
break break
except: except:
echo filename, " not found" echo filename, " not found"
doAssert(not keywords.isNil, "Couldn't read any keywords.txt file!") doAssert(not keywords.isNil, "Couldn't read any keywords.txt file!")
doAssert keywords.len == nimKeywords.len, "No matching lengths" for i in 0..min(keywords.len, nimKeywords.len)-1:
for i in 0..keywords.len-1:
#echo keywords[i], " == ", nimKeywords[i]
doAssert keywords[i] == nimKeywords[i], "Unexpected keyword" doAssert keywords[i] == nimKeywords[i], "Unexpected keyword"
doAssert keywords.len == nimKeywords.len, "No matching lengths"

View file

@ -4,8 +4,8 @@ discard """
type type
TFooContainer[T] = object TFooContainer[T] = object
TContainer[T] = generic var c TContainer[T] = concept var c
foo(c, T) foo(c, T)
proc foo[T](c: var TFooContainer[T], val: T) = proc foo[T](c: var TFooContainer[T], val: T) =