Skip to content

Commit b4fdb90

Browse files
rfundukmasatake
andauthored
Odin: add new parser (#4381)
* Odin: add new parser Add a C-crafted parser for the Odin programming language. Supported tag kinds: package, proc, const, var, struct, enum, union, member, enumerator, type, foreign, and more. The parser uses a naming-convention heuristic to distinguish type aliases from constants when the right-hand side of a :: binding is a plain identifier: Ada_Case names are tagged as types, and SCREAMING_SNAKE_CASE names as constants. This is documented in the new ctags-lang-odin(7) man page. https://odin-lang.org Co-authored-by: Masatake YAMATO <yamato@redhat.com>
1 parent 7fdf6a7 commit b4fdb90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2544
-0
lines changed

Tmain/extras-long.d/stdout-expected.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ z nulltag no NONE no 1 Include tags with empt
1414
- doubleSharps no IPythonCell no 0 Include cells starting from ##
1515
- configPrefixed yes Kconfig no 0 prepend CONFIG_ to config names
1616
- CppDef no Make no 1 Include FOO in -DFOO as as a name of CPreProcessor macro
17+
- implicitImportName yes Odin no 0 implicitly defined import name like "filepath" in "core:path/filepath"
1718
- guessedFromFileName yes PkgConfig no 0 the guessed package name of the .pc file
1819
- arityAppended yes Prolog no 0 Include predicates with their arities
1920
- funcmap yes QemuHX no 0 Include mapping SQMP to C function name
@@ -34,6 +35,7 @@ z nulltag no NONE no 1 Include tags with empt
3435
- doubleSharps no IPythonCell no 0 Include cells starting from ##
3536
- configPrefixed yes Kconfig no 0 prepend CONFIG_ to config names
3637
- CppDef no Make no 1 Include FOO in -DFOO as as a name of CPreProcessor macro
38+
- implicitImportName yes Odin no 0 implicitly defined import name like "filepath" in "core:path/filepath"
3739
- guessedFromFileName yes PkgConfig no 0 the guessed package name of the .pc file
3840
- arityAppended yes Prolog no 0 Include predicates with their arities
3941
- funcmap yes QemuHX no 0 Include mapping SQMP to C function name
@@ -54,6 +56,7 @@ z nulltag no NONE no 1 Include tags with empt
5456
- doubleSharps no IPythonCell no 0 Include cells starting from ##
5557
- configPrefixed yes Kconfig no 0 prepend CONFIG_ to config names
5658
- CppDef no Make no 1 Include FOO in -DFOO as as a name of CPreProcessor macro
59+
- implicitImportName yes Odin no 0 implicitly defined import name like "filepath" in "core:path/filepath"
5760
- guessedFromFileName yes PkgConfig no 0 the guessed package name of the .pc file
5861
- arityAppended yes Prolog no 0 Include predicates with their arities
5962
- funcmap yes QemuHX no 0 Include mapping SQMP to C function name
@@ -74,6 +77,7 @@ z nulltag no NONE no 1 Include tags with empt
7477
- doubleSharps no IPythonCell no 0 Include cells starting from ##
7578
- configPrefixed yes Kconfig no 0 prepend CONFIG_ to config names
7679
- CppDef no Make no 1 Include FOO in -DFOO as as a name of CPreProcessor macro
80+
- implicitImportName yes Odin no 0 implicitly defined import name like "filepath" in "core:path/filepath"
7781
- guessedFromFileName yes PkgConfig no 0 the guessed package name of the .pc file
7882
- arityAppended yes Prolog no 0 Include predicates with their arities
7983
- funcmap yes QemuHX no 0 Include mapping SQMP to C function name
@@ -94,6 +98,7 @@ z nulltag no NONE no 1 Include tags with empt
9498
- doubleSharps no IPythonCell no 0 Include cells starting from ##
9599
- configPrefixed yes Kconfig no 0 prepend CONFIG_ to config names
96100
- CppDef no Make no 1 Include FOO in -DFOO as as a name of CPreProcessor macro
101+
- implicitImportName yes Odin no 0 implicitly defined import name like "filepath" in "core:path/filepath"
97102
- guessedFromFileName yes PkgConfig no 0 the guessed package name of the .pc file
98103
- arityAppended yes Prolog no 0 Include predicates with their arities
99104
- funcmap yes QemuHX no 0 Include mapping SQMP to C function name

Tmain/list-extras.d/stdout-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ z nulltag yes NONE no 1 Include tags with empt
1414
- doubleSharps no IPythonCell no 0 Include cells starting from ##
1515
- configPrefixed yes Kconfig no 0 prepend CONFIG_ to config names
1616
- CppDef no Make no 1 Include FOO in -DFOO as as a name of CPreProcessor macro
17+
- implicitImportName yes Odin no 0 implicitly defined import name like "filepath" in "core:path/filepath"
1718
- guessedFromFileName yes PkgConfig no 0 the guessed package name of the .pc file
1819
- arityAppended yes Prolog no 0 Include predicates with their arities
1920
- funcmap yes QemuHX no 0 Include mapping SQMP to C function name
@@ -34,6 +35,7 @@ z nulltag yes NONE no 1 Include tags with empty strings as their names
3435
- doubleSharps no IPythonCell no 0 Include cells starting from ##
3536
- configPrefixed yes Kconfig no 0 prepend CONFIG_ to config names
3637
- CppDef no Make no 1 Include FOO in -DFOO as as a name of CPreProcessor macro
38+
- implicitImportName yes Odin no 0 implicitly defined import name like "filepath" in "core:path/filepath"
3739
- guessedFromFileName yes PkgConfig no 0 the guessed package name of the .pc file
3840
- arityAppended yes Prolog no 0 Include predicates with their arities
3941
- funcmap yes QemuHX no 0 Include mapping SQMP to C function name

Tmain/list-fields-with-prefix.d/stdout-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ x UCTAGSxpath no NONE s-- no -- 0 xpath
4141
- UCTAGSlangid yes NSIS s-- no -- 0 language identifier specified in (License)LangString commands
4242
- UCTAGScategory yes ObjectiveC s-- no -- 0 category attached to the class
4343
- UCTAGSprotocols yes ObjectiveC s-- no -- 0 protocols that the class (or category) confirms to
44+
- UCTAGSimportName yes Odin s-- no -- 0 import name for the imported entity
4445
- UCTAGShome yes Passwd s-- no rw 0 home directory
4546
- UCTAGSshell yes Passwd s-- no rw 0 login shell
4647
- UCTAGSarity yes Prolog -i- no -- 0 the number of parameters

Tmain/list-fields.d/stdout-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ z kind no NONE s-- no r- 0 [tags output] prepend "kind:" to k/ (or K/) field out
5959
- langid yes NSIS s-- no -- 0 language identifier specified in (License)LangString commands
6060
- category yes ObjectiveC s-- no -- 0 category attached to the class
6161
- protocols yes ObjectiveC s-- no -- 0 protocols that the class (or category) confirms to
62+
- importName yes Odin s-- no -- 0 import name for the imported entity
6263
- home yes Passwd s-- no rw 0 home directory
6364
- shell yes Passwd s-- no rw 0 login shell
6465
- arity yes Prolog -i- no -- 0 the number of parameters

Tmain/list-roles.d/stdout-expected.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ Meson m/module imported on 0 importe
9393
NSIS i/script included on 0 included with !include
9494
Nftables R/ruleset included on 0 included ruleset
9595
Nftables f/family referenced off 0 referenced somehow
96+
Odin A/asmfile imported on 0 imported assembly file via foreign
97+
Odin C/collection referenced on 0 referenced in import statement
98+
Odin L/ccode imported on 0 imported ccode via foreign
99+
Odin p/package imported on 0 imported package
96100
Perl M/module unused on 0 specified in `no' built-in function
97101
Perl M/module used on 0 specified in `use' built-in function
98102
Perl h/heredoc endmarker on 0 end marker
@@ -247,6 +251,10 @@ Meson m/module imported on 0 importe
247251
NSIS i/script included on 0 included with !include
248252
Nftables R/ruleset included on 0 included ruleset
249253
Nftables f/family referenced off 0 referenced somehow
254+
Odin A/asmfile imported on 0 imported assembly file via foreign
255+
Odin C/collection referenced on 0 referenced in import statement
256+
Odin L/ccode imported on 0 imported ccode via foreign
257+
Odin p/package imported on 0 imported package
250258
Perl M/module unused on 0 specified in `no' built-in function
251259
Perl M/module used on 0 specified in `use' built-in function
252260
Perl h/heredoc endmarker on 0 end marker
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--sort=no
2+
--fields=+K
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
attrs input.odin /^package attrs$/;" package
2+
internal_state input.odin /^internal_state := 10$/;" var package:attrs
3+
restore_mode input.odin /^restore_mode :: proc() {}$/;" proc package:attrs
4+
cleanup input.odin /^cleanup :: proc() {}$/;" proc package:attrs
5+
hidden input.odin /^hidden :: proc() {}$/;" proc package:attrs
6+
destroy input.odin /^destroy :: proc() {}$/;" proc package:attrs
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#+build linux, darwin
2+
package attrs
3+
4+
@(private)
5+
internal_state := 10
6+
7+
@(private = "file")
8+
restore_mode :: proc() {}
9+
10+
@(deprecated = "use destroy", private = "file")
11+
cleanup :: proc() {}
12+
13+
@private
14+
hidden :: proc() {}
15+
16+
destroy :: proc() {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--sort=no
2+
--fields=+ne
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
main input.odin /^package main$/;" p line:1
2+
Vec2 input.odin /^Vec2 :: struct {$/;" s line:3 package:main end:6
3+
x input.odin /^ x: f32,$/;" m line:4 struct:main.Vec2
4+
y input.odin /^ y: f32,$/;" m line:5 struct:main.Vec2
5+
Direction input.odin /^Direction :: enum {$/;" e line:8 package:main end:13
6+
North input.odin /^ North,$/;" n line:9 enum:main.Direction
7+
East input.odin /^ East,$/;" n line:10 enum:main.Direction
8+
South input.odin /^ South,$/;" n line:11 enum:main.Direction
9+
West input.odin /^ West,$/;" n line:12 enum:main.Direction
10+
add input.odin /^add :: proc(a, b: Vec2) -> Vec2 {$/;" f line:15 package:main end:17
11+
main input.odin /^main :: proc() {$/;" f line:19 package:main end:21

0 commit comments

Comments
 (0)