Fixes for const, short and function returning pointer
This commit is contained in:
parent
d3340d51e2
commit
4fe3b0380c
2 changed files with 21 additions and 9 deletions
|
|
@ -28,9 +28,18 @@ proc saveNodeData(node: TSNode): bool =
|
|||
if name in ["primitive_type", "sized_type_specifier"]:
|
||||
val = val.getType()
|
||||
|
||||
if node.tsNodeParent().tsNodeType() == "pointer_declarator":
|
||||
if gStateRT.data[^1].val != "object":
|
||||
gStateRT.data[^1].val = "ptr " & gStateRT.data[^1].val
|
||||
let
|
||||
nparent = node.tsNodeParent()
|
||||
if not nparent.tsNodeIsNull():
|
||||
let
|
||||
npname = nparent.tsNodeType()
|
||||
npparent = nparent.tsNodeParent()
|
||||
if npname == "pointer_declarator" or
|
||||
(npname == "function_declarator" and
|
||||
not npparent.tsNodeIsNull() and npparent.tsNodeType() == "pointer_declarator"):
|
||||
|
||||
if gStateRT.data[^1].val != "object":
|
||||
gStateRT.data[^1].val = "ptr " & gStateRT.data[^1].val
|
||||
|
||||
gStateRT.data.add((name, val))
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ proc initGrammar() =
|
|||
(type_definition
|
||||
(primitive_type|type_identifier?)
|
||||
(sized_type_specifier?
|
||||
(primitive_type)
|
||||
(primitive_type?)
|
||||
)
|
||||
(struct_specifier?
|
||||
(type_identifier)
|
||||
|
|
@ -95,7 +95,7 @@ proc initGrammar() =
|
|||
(field_declaration+
|
||||
(primitive_type|type_identifier?)
|
||||
(sized_type_specifier?
|
||||
(primitive_type)
|
||||
(primitive_type?)
|
||||
)
|
||||
(struct_specifier?
|
||||
(type_identifier)
|
||||
|
|
@ -171,9 +171,10 @@ proc initGrammar() =
|
|||
# typ function(typ param1, ...)
|
||||
gStateRT.grammar.add(("""
|
||||
(declaration
|
||||
(type_qualifier?)
|
||||
(primitive_type|type_identifier?)
|
||||
(sized_type_specifier?
|
||||
(primitive_type)
|
||||
(primitive_type?)
|
||||
)
|
||||
(struct_specifier?
|
||||
(type_identifier)
|
||||
|
|
@ -182,9 +183,10 @@ proc initGrammar() =
|
|||
(identifier)
|
||||
(parameter_list
|
||||
(parameter_declaration*
|
||||
(type_qualifier?)
|
||||
(primitive_type|type_identifier?)
|
||||
(sized_type_specifier?
|
||||
(primitive_type)
|
||||
(primitive_type?)
|
||||
)
|
||||
(struct_specifier?
|
||||
(type_identifier)
|
||||
|
|
@ -200,13 +202,14 @@ proc initGrammar() =
|
|||
)
|
||||
)
|
||||
(pointer_declarator?
|
||||
(function_declarator?
|
||||
(function_declarator
|
||||
(identifier)
|
||||
(parameter_list
|
||||
(parameter_declaration*
|
||||
(type_qualifier?)
|
||||
(primitive_type|type_identifier?)
|
||||
(sized_type_specifier?
|
||||
(primitive_type)
|
||||
(primitive_type?)
|
||||
)
|
||||
(struct_specifier?
|
||||
(type_identifier)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue