Identifiers in enums
This commit is contained in:
parent
8c644e814c
commit
75dc6dc56e
2 changed files with 16 additions and 10 deletions
|
|
@ -40,13 +40,12 @@ proc saveNodeData(node: TSNode): bool =
|
||||||
|
|
||||||
gStateRT.data.add((name, val))
|
gStateRT.data.add((name, val))
|
||||||
|
|
||||||
if node.isPName("pointer_declarator") and node.isPPName("function_declarator"):
|
if node.tsNodeType() == "field_identifier" and node.isPName("pointer_declarator") and
|
||||||
|
node.isPPName("function_declarator"):
|
||||||
gStateRT.data.add(("function_declarator", ""))
|
gStateRT.data.add(("function_declarator", ""))
|
||||||
|
|
||||||
elif name in ["abstract_pointer_declarator"]:
|
elif name in ["abstract_pointer_declarator", "enumerator", "field_declaration", "function_declarator"]:
|
||||||
gStateRT.data.add(("pointer_declarator", ""))
|
gStateRT.data.add((name.replace("abstract_", ""), ""))
|
||||||
elif name in ["field_declaration", "function_declarator"]:
|
|
||||||
gStateRT.data.add((name, ""))
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,10 @@ proc initGrammar() =
|
||||||
|
|
||||||
funcGrammar = &"""
|
funcGrammar = &"""
|
||||||
(function_declarator*
|
(function_declarator*
|
||||||
(identifier|type_identifier)
|
(identifier|type_identifier!)
|
||||||
|
(pointer_declarator
|
||||||
|
(type_identifier)
|
||||||
|
)
|
||||||
{paramListGrammar}
|
{paramListGrammar}
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
@ -123,7 +126,7 @@ proc initGrammar() =
|
||||||
if typ != "object":
|
if typ != "object":
|
||||||
gStateRT.typeStr &= &" {name}* = proc({pout}): {tptr}{typ} {{.nimcall.}}\n"
|
gStateRT.typeStr &= &" {name}* = proc({pout}): {tptr}{typ} {{.nimcall.}}\n"
|
||||||
else:
|
else:
|
||||||
gStateRT.typeStr &= &" {name}*: proc({pout}) {{.nimcall.}}\n"
|
gStateRT.typeStr &= &" {name}* = proc({pout}) {{.nimcall.}}\n"
|
||||||
else:
|
else:
|
||||||
gStateRT.types.add(name)
|
gStateRT.types.add(name)
|
||||||
if name == typ or typ == "object":
|
if name == typ or typ == "object":
|
||||||
|
|
@ -169,7 +172,7 @@ proc initGrammar() =
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if gStateRT.data[i].name notin ["field_identifier", "pointer_declarator"]:
|
if gStateRT.data[i].name notin ["field_identifier", "pointer_declarator"]:
|
||||||
ftyp = gStateRT.data[i].val.getIdentifier()
|
ftyp = gStateRT.data[i].val.getType()
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
if gStateRT.data[i].name == "pointer_declarator":
|
if gStateRT.data[i].name == "pointer_declarator":
|
||||||
|
|
@ -289,9 +292,13 @@ proc initGrammar() =
|
||||||
let
|
let
|
||||||
fname = gStateRT.data[i].val.getIdentifier()
|
fname = gStateRT.data[i].val.getIdentifier()
|
||||||
|
|
||||||
|
if gStateRT.data[i].name == "enumerator":
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
if fname notin gStateRT.consts:
|
if fname notin gStateRT.consts:
|
||||||
if i+1 < gStateRT.data.len-fend and
|
if i+1 < gStateRT.data.len-fend and
|
||||||
gStateRT.data[i+1].name in ["shift_expression", "math_expression", "number_literal"]:
|
gStateRT.data[i+1].name in ["identifier", "shift_expression", "math_expression", "number_literal"]:
|
||||||
if " " in gStateRT.data[i+1].val:
|
if " " in gStateRT.data[i+1].val:
|
||||||
gStateRT.data[i+1].val = "(" & gStateRT.data[i+1].val.replace(" ", "") & ")"
|
gStateRT.data[i+1].val = "(" & gStateRT.data[i+1].val.replace(" ", "") & ")"
|
||||||
gStateRT.data[i+1].val = gStateRT.data[i+1].val.multiReplace([
|
gStateRT.data[i+1].val = gStateRT.data[i+1].val.multiReplace([
|
||||||
|
|
@ -315,7 +322,7 @@ proc initGrammar() =
|
||||||
(type_identifier?)
|
(type_identifier?)
|
||||||
(enumerator_list
|
(enumerator_list
|
||||||
(enumerator+
|
(enumerator+
|
||||||
(identifier)
|
(identifier+)
|
||||||
(number_literal?)
|
(number_literal?)
|
||||||
(shift_expression|math_expression?
|
(shift_expression|math_expression?
|
||||||
(number_literal+)
|
(number_literal+)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue