tree-sitter-muttrc 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,224 @@
1
+ #ifndef TREE_SITTER_PARSER_H_
2
+ #define TREE_SITTER_PARSER_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include <stdbool.h>
9
+ #include <stdint.h>
10
+ #include <stdlib.h>
11
+
12
+ #define ts_builtin_sym_error ((TSSymbol)-1)
13
+ #define ts_builtin_sym_end 0
14
+ #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
15
+
16
+ typedef uint16_t TSStateId;
17
+
18
+ #ifndef TREE_SITTER_API_H_
19
+ typedef uint16_t TSSymbol;
20
+ typedef uint16_t TSFieldId;
21
+ typedef struct TSLanguage TSLanguage;
22
+ #endif
23
+
24
+ typedef struct {
25
+ TSFieldId field_id;
26
+ uint8_t child_index;
27
+ bool inherited;
28
+ } TSFieldMapEntry;
29
+
30
+ typedef struct {
31
+ uint16_t index;
32
+ uint16_t length;
33
+ } TSFieldMapSlice;
34
+
35
+ typedef struct {
36
+ bool visible;
37
+ bool named;
38
+ bool supertype;
39
+ } TSSymbolMetadata;
40
+
41
+ typedef struct TSLexer TSLexer;
42
+
43
+ struct TSLexer {
44
+ int32_t lookahead;
45
+ TSSymbol result_symbol;
46
+ void (*advance)(TSLexer *, bool);
47
+ void (*mark_end)(TSLexer *);
48
+ uint32_t (*get_column)(TSLexer *);
49
+ bool (*is_at_included_range_start)(const TSLexer *);
50
+ bool (*eof)(const TSLexer *);
51
+ };
52
+
53
+ typedef enum {
54
+ TSParseActionTypeShift,
55
+ TSParseActionTypeReduce,
56
+ TSParseActionTypeAccept,
57
+ TSParseActionTypeRecover,
58
+ } TSParseActionType;
59
+
60
+ typedef union {
61
+ struct {
62
+ uint8_t type;
63
+ TSStateId state;
64
+ bool extra;
65
+ bool repetition;
66
+ } shift;
67
+ struct {
68
+ uint8_t type;
69
+ uint8_t child_count;
70
+ TSSymbol symbol;
71
+ int16_t dynamic_precedence;
72
+ uint16_t production_id;
73
+ } reduce;
74
+ uint8_t type;
75
+ } TSParseAction;
76
+
77
+ typedef struct {
78
+ uint16_t lex_state;
79
+ uint16_t external_lex_state;
80
+ } TSLexMode;
81
+
82
+ typedef union {
83
+ TSParseAction action;
84
+ struct {
85
+ uint8_t count;
86
+ bool reusable;
87
+ } entry;
88
+ } TSParseActionEntry;
89
+
90
+ struct TSLanguage {
91
+ uint32_t version;
92
+ uint32_t symbol_count;
93
+ uint32_t alias_count;
94
+ uint32_t token_count;
95
+ uint32_t external_token_count;
96
+ uint32_t state_count;
97
+ uint32_t large_state_count;
98
+ uint32_t production_id_count;
99
+ uint32_t field_count;
100
+ uint16_t max_alias_sequence_length;
101
+ const uint16_t *parse_table;
102
+ const uint16_t *small_parse_table;
103
+ const uint32_t *small_parse_table_map;
104
+ const TSParseActionEntry *parse_actions;
105
+ const char * const *symbol_names;
106
+ const char * const *field_names;
107
+ const TSFieldMapSlice *field_map_slices;
108
+ const TSFieldMapEntry *field_map_entries;
109
+ const TSSymbolMetadata *symbol_metadata;
110
+ const TSSymbol *public_symbol_map;
111
+ const uint16_t *alias_map;
112
+ const TSSymbol *alias_sequences;
113
+ const TSLexMode *lex_modes;
114
+ bool (*lex_fn)(TSLexer *, TSStateId);
115
+ bool (*keyword_lex_fn)(TSLexer *, TSStateId);
116
+ TSSymbol keyword_capture_token;
117
+ struct {
118
+ const bool *states;
119
+ const TSSymbol *symbol_map;
120
+ void *(*create)(void);
121
+ void (*destroy)(void *);
122
+ bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
123
+ unsigned (*serialize)(void *, char *);
124
+ void (*deserialize)(void *, const char *, unsigned);
125
+ } external_scanner;
126
+ const TSStateId *primary_state_ids;
127
+ };
128
+
129
+ /*
130
+ * Lexer Macros
131
+ */
132
+
133
+ #define START_LEXER() \
134
+ bool result = false; \
135
+ bool skip = false; \
136
+ bool eof = false; \
137
+ int32_t lookahead; \
138
+ goto start; \
139
+ next_state: \
140
+ lexer->advance(lexer, skip); \
141
+ start: \
142
+ skip = false; \
143
+ lookahead = lexer->lookahead;
144
+
145
+ #define ADVANCE(state_value) \
146
+ { \
147
+ state = state_value; \
148
+ goto next_state; \
149
+ }
150
+
151
+ #define SKIP(state_value) \
152
+ { \
153
+ skip = true; \
154
+ state = state_value; \
155
+ goto next_state; \
156
+ }
157
+
158
+ #define ACCEPT_TOKEN(symbol_value) \
159
+ result = true; \
160
+ lexer->result_symbol = symbol_value; \
161
+ lexer->mark_end(lexer);
162
+
163
+ #define END_STATE() return result;
164
+
165
+ /*
166
+ * Parse Table Macros
167
+ */
168
+
169
+ #define SMALL_STATE(id) id - LARGE_STATE_COUNT
170
+
171
+ #define STATE(id) id
172
+
173
+ #define ACTIONS(id) id
174
+
175
+ #define SHIFT(state_value) \
176
+ {{ \
177
+ .shift = { \
178
+ .type = TSParseActionTypeShift, \
179
+ .state = state_value \
180
+ } \
181
+ }}
182
+
183
+ #define SHIFT_REPEAT(state_value) \
184
+ {{ \
185
+ .shift = { \
186
+ .type = TSParseActionTypeShift, \
187
+ .state = state_value, \
188
+ .repetition = true \
189
+ } \
190
+ }}
191
+
192
+ #define SHIFT_EXTRA() \
193
+ {{ \
194
+ .shift = { \
195
+ .type = TSParseActionTypeShift, \
196
+ .extra = true \
197
+ } \
198
+ }}
199
+
200
+ #define REDUCE(symbol_val, child_count_val, ...) \
201
+ {{ \
202
+ .reduce = { \
203
+ .type = TSParseActionTypeReduce, \
204
+ .symbol = symbol_val, \
205
+ .child_count = child_count_val, \
206
+ __VA_ARGS__ \
207
+ }, \
208
+ }}
209
+
210
+ #define RECOVER() \
211
+ {{ \
212
+ .type = TSParseActionTypeRecover \
213
+ }}
214
+
215
+ #define ACCEPT_INPUT() \
216
+ {{ \
217
+ .type = TSParseActionTypeAccept \
218
+ }}
219
+
220
+ #ifdef __cplusplus
221
+ }
222
+ #endif
223
+
224
+ #endif // TREE_SITTER_PARSER_H_
@@ -0,0 +1,2 @@
1
+ r"""{{name.replace("_", " ").strip().capitalize()}}."""
2
+
@@ -0,0 +1,12 @@
1
+ r"""{{name.replace("_", " ").strip().capitalize()}}.
2
+
3
+ {%for p in params-%}
4
+ :param {{p.argument}}:
5
+ {%if p.annotation-%}
6
+ :type {{p.argument}}: {{p.annotation.strip('"')}}
7
+ {%endif-%}
8
+ {%endfor-%}
9
+ {%if return_type-%}
10
+ :rtype: {{return_type}}
11
+ {%endif-%}
12
+ """
@@ -0,0 +1 @@
1
+ r"""{{name.replace("_", " ").strip().capitalize()}}."""
@@ -0,0 +1,82 @@
1
+ =======
2
+ Example
3
+ =======
4
+
5
+ bind pager,index \ch<BackSpace> sidebar-toggle-visible
6
+ set & allow_ansi ? allow_ansi noallow_ansi
7
+ set allow_ansi=yes
8
+ set sleep_time = 0
9
+ set real_name = $DEBFULLNAME
10
+ set ispell = aspell
11
+ set query_command = 'mutt_ldap_query.pl %s'
12
+ set signature = "echo Best Regards$'\n'$DEBFULLNAME|"
13
+ set imap_pass = `pass ls password/$USER`
14
+ mailboxes $spool_file $postponed $record $trash \
15
+ +[Gmail]/Spam +[Gmail]/Starred
16
+ sidebar_unpin *
17
+ source ~/.config/neomutt/neomuttrc
18
+
19
+ ---
20
+
21
+ (file
22
+ (bind_directive
23
+ (command)
24
+ (map)
25
+ (map)
26
+ (key
27
+ (escape)
28
+ (key_name))
29
+ (function))
30
+ (set_directive
31
+ (command)
32
+ (option)
33
+ (option)
34
+ (option))
35
+ (set_directive
36
+ (command)
37
+ (option)
38
+ (quadoption))
39
+ (set_directive
40
+ (command)
41
+ (option)
42
+ (int))
43
+ (set_directive
44
+ (command)
45
+ (option)
46
+ (shell))
47
+ (set_directive
48
+ (command)
49
+ (option)
50
+ (shell))
51
+ (set_directive
52
+ (command)
53
+ (option)
54
+ (string))
55
+ (set_directive
56
+ (command)
57
+ (option)
58
+ (shell))
59
+ (set_directive
60
+ (command)
61
+ (option)
62
+ (shell))
63
+ (mailboxes_directive
64
+ (command)
65
+ (mailbox
66
+ (shell))
67
+ (mailbox
68
+ (shell))
69
+ (mailbox
70
+ (shell))
71
+ (mailbox
72
+ (shell))
73
+ (mailbox
74
+ (shell))
75
+ (mailbox
76
+ (shell)))
77
+ (sidebar_unpin_directive
78
+ (command))
79
+ (source_directive
80
+ (command)
81
+ (path
82
+ (shell))))
@@ -0,0 +1,20 @@
1
+ bind pager,index \ch<BackSpace> sidebar-toggle-visible
2
+ set & allow_ansi ? allow_ansi noallow_ansi
3
+ set allow_ansi=yes
4
+ set sleep_time = 0
5
+ set real_name = $DEBFULLNAME
6
+ set ispell = aspell
7
+ set query_command = 'mutt_ldap_query.pl %s'
8
+ set signature = "echo Best Regards$'\n'$DEBFULLNAME|"
9
+ set imap_pass = `pass ls password/$USER`
10
+ mailboxes $spool_file $postponed $record $trash \
11
+ +[Gmail]/Spam +[Gmail]/Starred
12
+ sidebar_unpin *
13
+ source ~/.config/neomutt/neomuttrc
14
+
15
+ set my_config = ~/.config/neomutt/neomuttrc
16
+ folder-hook 'imaps://imap\..*\.gmail' source $my_config.gmail
17
+ # Refer https://neomutt.org/feature/compress#4-%C2%A0neomuttrc
18
+ open-hook '\.gz$' "gzip --stdout --decompress '%f' > '%t'"
19
+ color body color22 default "(http|https|ftp|news|telnet|finger)://[^ \">\t\r\n]*"
20
+ color body green default "[-a-z_0-9.%$]+ (<at>|AT) [-a-z_0-9.]+\\.[-a-z][-a-z]+"
@@ -0,0 +1,22 @@
1
+ r"""Test __init__.py."""
2
+
3
+ import os
4
+
5
+ from tree_sitter_muttrc import parser
6
+
7
+
8
+ class Test:
9
+ r"""Test."""
10
+
11
+ @staticmethod
12
+ def test_parser() -> None:
13
+ r"""Test parser.
14
+
15
+ :rtype: None
16
+ """
17
+ with open(
18
+ os.path.join(os.path.dirname(__file__), "neomuttrc"), "rb"
19
+ ) as f:
20
+ text = f.read()
21
+ tree = parser.parse(text)
22
+ assert len(tree.root_node.children)