Detect unknown
This commit is contained in:
parent
e9120eee78
commit
438160ac2a
2 changed files with 21 additions and 1 deletions
|
|
@ -320,6 +320,9 @@ proc getAstChildByName*(ast: ref Ast, name: string): ref Ast =
|
|||
if name in ast.children[i].name.split("|"):
|
||||
return ast.children[i]
|
||||
|
||||
if ast.children.len == 1 and ast.children[0].name == ".":
|
||||
return ast.children[0]
|
||||
|
||||
proc getPxName*(node: TSNode, offset: int): string =
|
||||
var
|
||||
np = node
|
||||
|
|
|
|||
|
|
@ -637,6 +637,23 @@ proc initGrammar(): Grammar =
|
|||
nimState.commentStr &= &"\n # {line.strip(leading=false)}"
|
||||
))
|
||||
|
||||
# // unknown
|
||||
result.add((&"""
|
||||
(type_definition|struct_specifier|union_specifier|enum_specifier|declaration
|
||||
(^.*)
|
||||
)
|
||||
""",
|
||||
proc (ast: ref Ast, node: TSNode, nimState: NimState) =
|
||||
for i in nimState.data:
|
||||
case $node.tsNodeType()
|
||||
of "declaration":
|
||||
if i.name == "identifier":
|
||||
echo "# Unknown declaration " & i.val
|
||||
else:
|
||||
if i.name == "type_identifier":
|
||||
echo "# Unknown type " & i.val
|
||||
))
|
||||
|
||||
proc initRegex(ast: ref Ast) =
|
||||
if ast.children.len != 0:
|
||||
if not ast.recursive:
|
||||
|
|
@ -653,7 +670,7 @@ proc initRegex(ast: ref Ast) =
|
|||
raise newException(Exception, getCurrentExceptionMsg())
|
||||
|
||||
proc parseGrammar*(): AstTable =
|
||||
let grammars = initGrammar()
|
||||
const grammars = initGrammar()
|
||||
|
||||
result = newTable[string, seq[ref Ast]]()
|
||||
for i in 0 .. grammars.len-1:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue