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,7 +28,16 @@ proc saveNodeData(node: TSNode): bool =
|
||||||
if name in ["primitive_type", "sized_type_specifier"]:
|
if name in ["primitive_type", "sized_type_specifier"]:
|
||||||
val = val.getType()
|
val = val.getType()
|
||||||
|
|
||||||
if node.tsNodeParent().tsNodeType() == "pointer_declarator":
|
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":
|
if gStateRT.data[^1].val != "object":
|
||||||
gStateRT.data[^1].val = "ptr " & gStateRT.data[^1].val
|
gStateRT.data[^1].val = "ptr " & gStateRT.data[^1].val
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ proc initGrammar() =
|
||||||
(type_definition
|
(type_definition
|
||||||
(primitive_type|type_identifier?)
|
(primitive_type|type_identifier?)
|
||||||
(sized_type_specifier?
|
(sized_type_specifier?
|
||||||
(primitive_type)
|
(primitive_type?)
|
||||||
)
|
)
|
||||||
(struct_specifier?
|
(struct_specifier?
|
||||||
(type_identifier)
|
(type_identifier)
|
||||||
|
|
@ -95,7 +95,7 @@ proc initGrammar() =
|
||||||
(field_declaration+
|
(field_declaration+
|
||||||
(primitive_type|type_identifier?)
|
(primitive_type|type_identifier?)
|
||||||
(sized_type_specifier?
|
(sized_type_specifier?
|
||||||
(primitive_type)
|
(primitive_type?)
|
||||||
)
|
)
|
||||||
(struct_specifier?
|
(struct_specifier?
|
||||||
(type_identifier)
|
(type_identifier)
|
||||||
|
|
@ -171,9 +171,10 @@ proc initGrammar() =
|
||||||
# typ function(typ param1, ...)
|
# typ function(typ param1, ...)
|
||||||
gStateRT.grammar.add(("""
|
gStateRT.grammar.add(("""
|
||||||
(declaration
|
(declaration
|
||||||
|
(type_qualifier?)
|
||||||
(primitive_type|type_identifier?)
|
(primitive_type|type_identifier?)
|
||||||
(sized_type_specifier?
|
(sized_type_specifier?
|
||||||
(primitive_type)
|
(primitive_type?)
|
||||||
)
|
)
|
||||||
(struct_specifier?
|
(struct_specifier?
|
||||||
(type_identifier)
|
(type_identifier)
|
||||||
|
|
@ -182,9 +183,10 @@ proc initGrammar() =
|
||||||
(identifier)
|
(identifier)
|
||||||
(parameter_list
|
(parameter_list
|
||||||
(parameter_declaration*
|
(parameter_declaration*
|
||||||
|
(type_qualifier?)
|
||||||
(primitive_type|type_identifier?)
|
(primitive_type|type_identifier?)
|
||||||
(sized_type_specifier?
|
(sized_type_specifier?
|
||||||
(primitive_type)
|
(primitive_type?)
|
||||||
)
|
)
|
||||||
(struct_specifier?
|
(struct_specifier?
|
||||||
(type_identifier)
|
(type_identifier)
|
||||||
|
|
@ -200,13 +202,14 @@ proc initGrammar() =
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(pointer_declarator?
|
(pointer_declarator?
|
||||||
(function_declarator?
|
(function_declarator
|
||||||
(identifier)
|
(identifier)
|
||||||
(parameter_list
|
(parameter_list
|
||||||
(parameter_declaration*
|
(parameter_declaration*
|
||||||
|
(type_qualifier?)
|
||||||
(primitive_type|type_identifier?)
|
(primitive_type|type_identifier?)
|
||||||
(sized_type_specifier?
|
(sized_type_specifier?
|
||||||
(primitive_type)
|
(primitive_type?)
|
||||||
)
|
)
|
||||||
(struct_specifier?
|
(struct_specifier?
|
||||||
(type_identifier)
|
(type_identifier)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue