Allow skip of symbol with _
This commit is contained in:
parent
70aa3e2b5e
commit
b86a128456
1 changed files with 19 additions and 16 deletions
|
|
@ -87,26 +87,29 @@ proc getType*(str: string): string =
|
||||||
if gTypeMap.hasKey(result):
|
if gTypeMap.hasKey(result):
|
||||||
result = gTypeMap[result]
|
result = gTypeMap[result]
|
||||||
|
|
||||||
template checkUnderscores(str, errmsg: string): untyped =
|
template checkUnderscores(name, errmsg: string): untyped =
|
||||||
if str.len != 0:
|
if name.len != 0:
|
||||||
doAssert str[0] != '_' and str[^1] != '_', errmsg
|
doAssert name[0] != '_' and name[^1] != '_', errmsg
|
||||||
|
|
||||||
proc getIdentifier*(str: string, kind: NimSymKind): string =
|
proc getIdentifier*(name: string, kind: NimSymKind): string =
|
||||||
doAssert str.len != 0, "Blank identifier error"
|
doAssert name.len != 0, "Blank identifier error"
|
||||||
|
|
||||||
if gStateRT.onSymbol != nil:
|
if name notin gStateRT.symOverride:
|
||||||
var
|
if gStateRT.onSymbol != nil:
|
||||||
sym = Symbol(name: str, kind: kind)
|
var
|
||||||
gStateRT.onSymbol(sym)
|
sym = Symbol(name: name, kind: kind)
|
||||||
|
gStateRT.onSymbol(sym)
|
||||||
|
|
||||||
result = sym.name
|
result = sym.name
|
||||||
checkUnderscores(result, &"Identifier '{str}' still contains leading/trailing underscores '_' after 'cPlugin:onSymbol()': result '{result}'")
|
checkUnderscores(result, &"Identifier '{name}' still contains leading/trailing underscores '_' after 'cPlugin:onSymbol()': result '{result}'")
|
||||||
|
else:
|
||||||
|
result = name
|
||||||
|
checkUnderscores(result, &"Identifier '{result}' contains unsupported leading/trailing underscores '_': use 'cPlugin:onSymbol()' to remove")
|
||||||
|
|
||||||
|
if result in gReserved:
|
||||||
|
result = &"`{result}`"
|
||||||
else:
|
else:
|
||||||
result = str
|
result = ""
|
||||||
checkUnderscores(result, &"Identifier '{result}' contains unsupported leading/trailing underscores '_': use 'cPlugin:onSymbol()' to remove")
|
|
||||||
|
|
||||||
if result in gReserved:
|
|
||||||
result = &"`{result}`"
|
|
||||||
|
|
||||||
proc getUniqueIdentifier*(existing: TableRef[string, string], prefix = ""): string =
|
proc getUniqueIdentifier*(existing: TableRef[string, string], prefix = ""): string =
|
||||||
var
|
var
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue