diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2019-10-17 15:41:24 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2019-10-17 15:41:24 -0500 |
| commit | 438160ac2a916ca0e8e18161d0a757e6bb338426 (patch) | |
| tree | 122e1a2ddca16b882378121f794909be9ada803a | |
| parent | e9120eee7840851bda8113afbc71062b29fff872 (diff) | |
| download | nimterop-438160ac2a916ca0e8e18161d0a757e6bb338426.tar.gz nimterop-438160ac2a916ca0e8e18161d0a757e6bb338426.zip | |
Detect unknown
| -rw-r--r-- | nimterop/getters.nim | 3 | ||||
| -rw-r--r-- | nimterop/grammar.nim | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/nimterop/getters.nim b/nimterop/getters.nim index a88895d..7205213 100644 --- a/nimterop/getters.nim +++ b/nimterop/getters.nim @@ -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 diff --git a/nimterop/grammar.nim b/nimterop/grammar.nim index 8d98dde..89b3223 100644 --- a/nimterop/grammar.nim +++ b/nimterop/grammar.nim @@ -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: |
