@futpib/parser 1.0.3 → 1.0.6

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.
Files changed (262) hide show
  1. package/.claude/settings.local.json +24 -0
  2. package/.github/workflows/main.yml +1 -0
  3. package/build/androidPackageParser.js +30 -32
  4. package/build/arbitraryDalvikBytecode.d.ts +3 -3
  5. package/build/arbitraryDalvikBytecode.js +33 -27
  6. package/build/arbitraryDalvikExecutable.js +55 -17
  7. package/build/arbitraryJava.d.ts +31 -0
  8. package/build/arbitraryJava.js +532 -0
  9. package/build/arbitraryJavaScript.d.ts +3 -0
  10. package/build/arbitraryJavaScript.js +263 -0
  11. package/build/arbitraryJavascript.d.ts +3 -0
  12. package/build/arbitraryJavascript.js +263 -0
  13. package/build/arbitraryZig.d.ts +3 -0
  14. package/build/arbitraryZig.js +240 -0
  15. package/build/arbitraryZipStream.d.ts +1 -1
  16. package/build/arrayParser.js +72 -13
  17. package/build/backsmali.d.ts +4 -3
  18. package/build/backsmali.js +26 -6
  19. package/build/bash.d.ts +89 -0
  20. package/build/bash.js +1 -0
  21. package/build/bashParser.d.ts +6 -0
  22. package/build/bashParser.js +335 -0
  23. package/build/bashParser.test.d.ts +1 -0
  24. package/build/bashParser.test.js +343 -0
  25. package/build/bashParserEdgeCases.test.d.ts +1 -0
  26. package/build/bashParserEdgeCases.test.js +117 -0
  27. package/build/dalvikBytecodeParser/addressConversion.d.ts +110 -0
  28. package/build/dalvikBytecodeParser/addressConversion.js +334 -0
  29. package/build/dalvikBytecodeParser/formatParsers.d.ts +7 -6
  30. package/build/dalvikBytecodeParser/formatParsers.js +13 -14
  31. package/build/dalvikBytecodeParser.d.ts +60 -31
  32. package/build/dalvikBytecodeParser.js +92 -35
  33. package/build/dalvikBytecodeParser.test-d.d.ts +1 -0
  34. package/build/dalvikBytecodeParser.test-d.js +268 -0
  35. package/build/dalvikBytecodeUnparser/formatUnparsers.d.ts +9 -8
  36. package/build/dalvikBytecodeUnparser/formatUnparsers.js +13 -12
  37. package/build/dalvikBytecodeUnparser.d.ts +2 -2
  38. package/build/dalvikBytecodeUnparser.js +23 -23
  39. package/build/dalvikBytecodeUnparser.test.js +7 -7
  40. package/build/dalvikExecutable.d.ts +3 -3
  41. package/build/dalvikExecutable.test-d.d.ts +1 -0
  42. package/build/dalvikExecutable.test-d.js +59 -0
  43. package/build/dalvikExecutableParser/typedNumbers.d.ts +18 -0
  44. package/build/dalvikExecutableParser/typedNumbers.js +3 -0
  45. package/build/dalvikExecutableParser.d.ts +2 -1
  46. package/build/dalvikExecutableParser.js +96 -77
  47. package/build/dalvikExecutableParser.test.js +24 -3
  48. package/build/dalvikExecutableParserAgainstSmaliParser.test.js +3 -0
  49. package/build/dalvikExecutableUnparser/poolScanners.d.ts +2 -2
  50. package/build/dalvikExecutableUnparser/sectionUnparsers.d.ts +3 -3
  51. package/build/dalvikExecutableUnparser/sectionUnparsers.js +26 -11
  52. package/build/dalvikExecutableUnparser.d.ts +2 -2
  53. package/build/dalvikExecutableUnparser.test.js +2 -1
  54. package/build/disjunctionParser.d.ts +5 -3
  55. package/build/disjunctionParser.js +79 -17
  56. package/build/disjunctionParser.test-d.d.ts +1 -0
  57. package/build/disjunctionParser.test-d.js +72 -0
  58. package/build/elementSwitchParser.d.ts +4 -0
  59. package/build/{exactElementSwitchParser.js → elementSwitchParser.js} +3 -4
  60. package/build/elementSwitchParser.test-d.d.ts +1 -0
  61. package/build/elementSwitchParser.test-d.js +44 -0
  62. package/build/exactSequenceParser.d.ts +4 -2
  63. package/build/exactSequenceParser.test-d.d.ts +1 -0
  64. package/build/exactSequenceParser.test-d.js +36 -0
  65. package/build/fetchCid.js +2 -66
  66. package/build/index.d.ts +25 -2
  67. package/build/index.js +23 -1
  68. package/build/index.test.js +16 -1
  69. package/build/inputReader.d.ts +10 -0
  70. package/build/inputReader.js +36 -0
  71. package/build/java.d.ts +502 -0
  72. package/build/java.js +2 -0
  73. package/build/javaKeyStoreParser.js +14 -17
  74. package/build/javaParser.d.ts +51 -0
  75. package/build/javaParser.js +1538 -0
  76. package/build/javaParser.test.d.ts +1 -0
  77. package/build/javaParser.test.js +1287 -0
  78. package/build/javaScript.d.ts +35 -0
  79. package/build/javaScript.js +1 -0
  80. package/build/javaScriptParser.d.ts +9 -0
  81. package/build/javaScriptParser.js +34 -0
  82. package/build/javaScriptUnparser.d.ts +3 -0
  83. package/build/javaScriptUnparser.js +4 -0
  84. package/build/javaScriptUnparser.test.d.ts +1 -0
  85. package/build/javaScriptUnparser.test.js +24 -0
  86. package/build/javaUnparser.d.ts +2 -0
  87. package/build/javaUnparser.js +519 -0
  88. package/build/javaUnparser.test.d.ts +1 -0
  89. package/build/javaUnparser.test.js +24 -0
  90. package/build/javascript.d.ts +35 -0
  91. package/build/javascript.js +1 -0
  92. package/build/javascriptParser.d.ts +9 -0
  93. package/build/javascriptParser.js +34 -0
  94. package/build/javascriptUnparser.d.ts +3 -0
  95. package/build/javascriptUnparser.js +4 -0
  96. package/build/javascriptUnparser.test.d.ts +1 -0
  97. package/build/javascriptUnparser.test.js +24 -0
  98. package/build/jsonParser.js +2 -12
  99. package/build/lazyMessageError.d.ts +3 -0
  100. package/build/lookaheadParser.js +60 -3
  101. package/build/negativeLookaheadParser.js +70 -11
  102. package/build/nonEmptyArrayParser.js +72 -13
  103. package/build/objectParser.d.ts +12 -0
  104. package/build/objectParser.js +31 -0
  105. package/build/objectParser.test-d.d.ts +1 -0
  106. package/build/objectParser.test-d.js +112 -0
  107. package/build/objectParser.test.d.ts +1 -0
  108. package/build/objectParser.test.js +55 -0
  109. package/build/optionalParser.js +69 -10
  110. package/build/parser.d.ts +4 -0
  111. package/build/parser.js +3 -1
  112. package/build/parser.test.js +114 -1
  113. package/build/parserConsumedSequenceParser.js +66 -7
  114. package/build/parserContext.d.ts +6 -0
  115. package/build/parserContext.js +20 -11
  116. package/build/parserError.d.ts +119 -27
  117. package/build/parserError.js +16 -8
  118. package/build/regexpParser.d.ts +2 -0
  119. package/build/regexpParser.js +101 -0
  120. package/build/regexpParser.test.d.ts +1 -0
  121. package/build/regexpParser.test.js +114 -0
  122. package/build/regularExpression.d.ts +63 -0
  123. package/build/regularExpression.js +1 -0
  124. package/build/regularExpressionParser.d.ts +3 -0
  125. package/build/regularExpressionParser.js +600 -0
  126. package/build/regularExpressionParser.test.d.ts +1 -0
  127. package/build/regularExpressionParser.test.js +89 -0
  128. package/build/separatedArrayParser.js +73 -14
  129. package/build/separatedNonEmptyArrayParser.js +73 -14
  130. package/build/sliceBoundedParser.js +62 -5
  131. package/build/smaliParser.d.ts +7 -7
  132. package/build/smaliParser.js +185 -268
  133. package/build/smaliParser.test.js +58 -0
  134. package/build/stringEscapes.d.ts +5 -0
  135. package/build/stringEscapes.js +244 -0
  136. package/build/symbolicExpression.d.ts +29 -0
  137. package/build/symbolicExpression.js +1 -0
  138. package/build/symbolicExpressionParser.d.ts +4 -0
  139. package/build/symbolicExpressionParser.js +123 -0
  140. package/build/symbolicExpressionParser.test.d.ts +1 -0
  141. package/build/symbolicExpressionParser.test.js +289 -0
  142. package/build/terminatedArrayParser.js +113 -38
  143. package/build/terminatedArrayParser.test.js +4 -2
  144. package/build/tupleParser.d.ts +7 -15
  145. package/build/tupleParser.js +1 -0
  146. package/build/unionParser.d.ts +5 -3
  147. package/build/unionParser.js +7 -2
  148. package/build/unionParser.test-d.d.ts +1 -0
  149. package/build/unionParser.test-d.js +72 -0
  150. package/build/unionParser.test.js +10 -11
  151. package/build/zig.d.ts +280 -0
  152. package/build/zig.js +2 -0
  153. package/build/zigParser.d.ts +3 -0
  154. package/build/zigParser.js +1119 -0
  155. package/build/zigParser.test.d.ts +1 -0
  156. package/build/zigParser.test.js +1590 -0
  157. package/build/zigUnparser.d.ts +2 -0
  158. package/build/zigUnparser.js +460 -0
  159. package/build/zigUnparser.test.d.ts +1 -0
  160. package/build/zigUnparser.test.js +24 -0
  161. package/build/zipParser.js +19 -32
  162. package/build/zipUnparser.js +19 -7
  163. package/build/zipUnparser.test.js +1 -1
  164. package/node_modules-@types/s-expression/index.d.ts +5 -0
  165. package/package.json +25 -6
  166. package/src/androidPackageParser.ts +33 -60
  167. package/src/arbitraryDalvikBytecode.ts +39 -31
  168. package/src/arbitraryDalvikExecutable.ts +65 -20
  169. package/src/arbitraryJava.ts +804 -0
  170. package/src/arbitraryJavaScript.ts +410 -0
  171. package/src/arbitraryZig.ts +380 -0
  172. package/src/arrayParser.ts +1 -3
  173. package/src/backsmali.ts +35 -4
  174. package/src/bash.ts +127 -0
  175. package/src/bashParser.test.ts +590 -0
  176. package/src/bashParser.ts +498 -0
  177. package/src/dalvikBytecodeParser/addressConversion.ts +496 -0
  178. package/src/dalvikBytecodeParser/formatParsers.ts +19 -29
  179. package/src/dalvikBytecodeParser.test-d.ts +310 -0
  180. package/src/dalvikBytecodeParser.ts +194 -69
  181. package/src/dalvikBytecodeUnparser/formatUnparsers.ts +27 -26
  182. package/src/dalvikBytecodeUnparser.test.ts +7 -7
  183. package/src/dalvikBytecodeUnparser.ts +31 -30
  184. package/src/dalvikExecutable.test-d.ts +132 -0
  185. package/src/dalvikExecutable.ts +3 -3
  186. package/src/dalvikExecutableParser/typedNumbers.ts +11 -0
  187. package/src/dalvikExecutableParser.test.ts +37 -3
  188. package/src/dalvikExecutableParser.test.ts.md +163 -2
  189. package/src/dalvikExecutableParser.test.ts.snap +0 -0
  190. package/src/dalvikExecutableParser.ts +121 -139
  191. package/src/dalvikExecutableParserAgainstSmaliParser.test.ts +4 -0
  192. package/src/dalvikExecutableUnparser/poolScanners.ts +6 -6
  193. package/src/dalvikExecutableUnparser/sectionUnparsers.ts +38 -14
  194. package/src/dalvikExecutableUnparser.test.ts +3 -2
  195. package/src/dalvikExecutableUnparser.ts +4 -4
  196. package/src/disjunctionParser.test-d.ts +105 -0
  197. package/src/disjunctionParser.ts +18 -15
  198. package/src/elementSwitchParser.test-d.ts +74 -0
  199. package/src/elementSwitchParser.ts +51 -0
  200. package/src/exactSequenceParser.test-d.ts +43 -0
  201. package/src/exactSequenceParser.ts +13 -8
  202. package/src/fetchCid.ts +2 -76
  203. package/src/index.test.ts +22 -1
  204. package/src/index.ts +119 -2
  205. package/src/inputReader.ts +53 -0
  206. package/src/java.ts +708 -0
  207. package/src/javaKeyStoreParser.ts +18 -32
  208. package/src/javaParser.test.ts +1592 -0
  209. package/src/javaParser.ts +2640 -0
  210. package/src/javaScript.ts +36 -0
  211. package/src/javaScriptParser.ts +57 -0
  212. package/src/javaScriptUnparser.test.ts +37 -0
  213. package/src/javaScriptUnparser.ts +7 -0
  214. package/src/javaUnparser.test.ts +37 -0
  215. package/src/javaUnparser.ts +640 -0
  216. package/src/jsonParser.ts +6 -27
  217. package/src/lookaheadParser.ts +2 -6
  218. package/src/negativeLookaheadParser.ts +1 -3
  219. package/src/nonEmptyArrayParser.ts +1 -3
  220. package/src/objectParser.test-d.ts +152 -0
  221. package/src/objectParser.test.ts +71 -0
  222. package/src/objectParser.ts +69 -0
  223. package/src/optionalParser.ts +1 -3
  224. package/src/parser.test.ts +151 -4
  225. package/src/parser.ts +11 -1
  226. package/src/parserConsumedSequenceParser.ts +2 -4
  227. package/src/parserContext.ts +26 -11
  228. package/src/parserError.ts +17 -3
  229. package/src/regexpParser.test.ts +264 -0
  230. package/src/regexpParser.ts +126 -0
  231. package/src/regularExpression.ts +24 -0
  232. package/src/regularExpressionParser.test.ts +102 -0
  233. package/src/regularExpressionParser.ts +920 -0
  234. package/src/separatedArrayParser.ts +1 -3
  235. package/src/separatedNonEmptyArrayParser.ts +1 -3
  236. package/src/sliceBoundedParser.test.ts +2 -2
  237. package/src/sliceBoundedParser.ts +15 -19
  238. package/src/smaliParser.test.ts +64 -0
  239. package/src/smaliParser.test.ts.md +12 -12
  240. package/src/smaliParser.test.ts.snap +0 -0
  241. package/src/smaliParser.ts +246 -534
  242. package/src/stringEscapes.ts +253 -0
  243. package/src/symbolicExpression.ts +17 -0
  244. package/src/symbolicExpressionParser.test.ts +466 -0
  245. package/src/symbolicExpressionParser.ts +190 -0
  246. package/src/terminatedArrayParser.test.ts +9 -6
  247. package/src/terminatedArrayParser.ts +25 -29
  248. package/src/tupleParser.ts +21 -18
  249. package/src/unionParser.test-d.ts +105 -0
  250. package/src/unionParser.test.ts +18 -17
  251. package/src/unionParser.ts +28 -16
  252. package/src/zig.ts +411 -0
  253. package/src/zigParser.test.ts +1693 -0
  254. package/src/zigParser.ts +1745 -0
  255. package/src/zigUnparser.test.ts +37 -0
  256. package/src/zigUnparser.ts +615 -0
  257. package/src/zipParser.ts +20 -56
  258. package/src/zipUnparser.test.ts +1 -1
  259. package/src/zipUnparser.ts +22 -7
  260. package/tsconfig.json +2 -2
  261. package/build/exactElementSwitchParser.d.ts +0 -3
  262. package/src/exactElementSwitchParser.ts +0 -41
@@ -27,17 +27,16 @@ test('union of union of union', async (t) => {
27
27
  }
28
28
  });
29
29
  test('sync and async child parsers', async (t) => {
30
- const parser = createArrayParser(createUnionParser([
31
- async (parserContext) => {
32
- parserContext.invariant(parserContext.position % 2 === 0, 'Expected an even position.');
33
- return parserContext.read(0);
34
- },
35
- parserContext => {
36
- parserContext.invariant(parserContext.position % 2 === 1, 'Expected an odd position.');
37
- parserContext.skip(1);
38
- return String.fromCodePoint('A'.codePointAt(0) + parserContext.position - 1);
39
- },
40
- ]));
30
+ const evenParser = async (parserContext) => {
31
+ parserContext.invariant(parserContext.position % 2 === 0, 'Expected an even position.');
32
+ return parserContext.read(0);
33
+ };
34
+ const oddParser = parserContext => {
35
+ parserContext.invariant(parserContext.position % 2 === 1, 'Expected an odd position.');
36
+ parserContext.skip(1);
37
+ return String.fromCodePoint('A'.codePointAt(0) + parserContext.position - 1);
38
+ };
39
+ const parser = createArrayParser(createUnionParser([evenParser, oddParser]));
41
40
  const result = await runParser(parser, 'a?c?', stringParserInputCompanion, {
42
41
  errorJoinMode: 'all',
43
42
  });
package/build/zig.d.ts ADDED
@@ -0,0 +1,280 @@
1
+ export type ZigIdentifier = {
2
+ type: 'Identifier';
3
+ name: string;
4
+ };
5
+ export type ZigIntegerLiteral = {
6
+ type: 'IntegerLiteral';
7
+ value: string;
8
+ };
9
+ export type ZigFloatLiteral = {
10
+ type: 'FloatLiteral';
11
+ value: string;
12
+ };
13
+ export type ZigStringLiteral = {
14
+ type: 'StringLiteral';
15
+ value: string;
16
+ };
17
+ export type ZigMultilineStringLiteral = {
18
+ type: 'MultilineStringLiteral';
19
+ value: string;
20
+ };
21
+ export type ZigCharLiteral = {
22
+ type: 'CharLiteral';
23
+ value: string;
24
+ };
25
+ export type ZigEnumLiteral = {
26
+ type: 'EnumLiteral';
27
+ name: string;
28
+ };
29
+ export type ZigBoolLiteral = {
30
+ type: 'BoolLiteral';
31
+ value: boolean;
32
+ };
33
+ export type ZigNullLiteral = {
34
+ type: 'NullLiteral';
35
+ };
36
+ export type ZigUndefinedLiteral = {
37
+ type: 'UndefinedLiteral';
38
+ };
39
+ export type ZigLiteral = ZigIntegerLiteral | ZigFloatLiteral | ZigStringLiteral | ZigMultilineStringLiteral | ZigCharLiteral | ZigEnumLiteral | ZigBoolLiteral | ZigNullLiteral | ZigUndefinedLiteral;
40
+ export type ZigIdentifierType = {
41
+ type: 'IdentifierType';
42
+ name: string;
43
+ };
44
+ export type ZigPointerType = {
45
+ type: 'PointerType';
46
+ size: 'one' | 'many' | 'slice';
47
+ isConst: boolean;
48
+ sentinel?: ZigExpression;
49
+ child: ZigTypeExpression;
50
+ };
51
+ export type ZigArrayType = {
52
+ type: 'ArrayType';
53
+ length: ZigExpression;
54
+ sentinel?: ZigExpression;
55
+ child: ZigTypeExpression;
56
+ };
57
+ export type ZigOptionalType = {
58
+ type: 'OptionalType';
59
+ child: ZigTypeExpression;
60
+ };
61
+ export type ZigErrorUnionType = {
62
+ type: 'ErrorUnionType';
63
+ error: ZigTypeExpression;
64
+ payload: ZigTypeExpression;
65
+ };
66
+ export type ZigDotType = {
67
+ type: 'DotType';
68
+ operand: ZigTypeExpression;
69
+ member: string;
70
+ };
71
+ export type ZigBuiltinType = {
72
+ type: 'BuiltinType';
73
+ name: string;
74
+ };
75
+ export type ZigFnProtoType = {
76
+ type: 'FnProtoType';
77
+ params: ZigFnParam[];
78
+ returnType: ZigTypeExpression;
79
+ };
80
+ export type ZigTypeExpression = ZigIdentifierType | ZigPointerType | ZigArrayType | ZigOptionalType | ZigErrorUnionType | ZigDotType | ZigBuiltinType | ZigFnProtoType | ZigExpression;
81
+ export type ZigBinaryOp = '+' | '-' | '*' | '/' | '%' | '<<' | '>>' | '&' | '|' | '^' | '==' | '!=' | '<' | '>' | '<=' | '>=' | 'and' | 'or' | '++' | '**' | 'orelse' | 'catch';
82
+ export type ZigBinaryExpr = {
83
+ type: 'BinaryExpr';
84
+ operator: ZigBinaryOp;
85
+ left: ZigExpression;
86
+ right: ZigExpression;
87
+ };
88
+ export type ZigUnaryOp = '-' | '~' | '!' | '&';
89
+ export type ZigUnaryExpr = {
90
+ type: 'UnaryExpr';
91
+ operator: string;
92
+ operand: ZigExpression;
93
+ };
94
+ export type ZigFieldAccessExpr = {
95
+ type: 'FieldAccessExpr';
96
+ operand: ZigExpression;
97
+ member: string;
98
+ };
99
+ export type ZigIndexExpr = {
100
+ type: 'IndexExpr';
101
+ operand: ZigExpression;
102
+ index: ZigExpression;
103
+ };
104
+ export type ZigSliceExpr = {
105
+ type: 'SliceExpr';
106
+ operand: ZigExpression;
107
+ start: ZigExpression;
108
+ end?: ZigExpression;
109
+ sentinel?: ZigExpression;
110
+ };
111
+ export type ZigCallExpr = {
112
+ type: 'CallExpr';
113
+ callee: ZigExpression;
114
+ args: ZigExpression[];
115
+ };
116
+ export type ZigBuiltinCallExpr = {
117
+ type: 'BuiltinCallExpr';
118
+ name: string;
119
+ args: ZigExpression[];
120
+ };
121
+ export type ZigIfExpr = {
122
+ type: 'IfExpr';
123
+ condition: ZigExpression;
124
+ capture?: string;
125
+ body: ZigStatement;
126
+ elseCapture?: string;
127
+ elseBody?: ZigStatement;
128
+ };
129
+ export type ZigSwitchProng = {
130
+ type: 'SwitchProng';
131
+ cases: ZigExpression[];
132
+ isElse: boolean;
133
+ capture?: string;
134
+ body: ZigExpression;
135
+ };
136
+ export type ZigSwitchExpr = {
137
+ type: 'SwitchExpr';
138
+ operand: ZigExpression;
139
+ prongs: ZigSwitchProng[];
140
+ };
141
+ export type ZigStructInitField = {
142
+ type: 'StructInitField';
143
+ name: string;
144
+ value: ZigExpression;
145
+ };
146
+ export type ZigStructInitExpr = {
147
+ type: 'StructInitExpr';
148
+ operand?: ZigExpression;
149
+ fields: ZigStructInitField[];
150
+ };
151
+ export type ZigArrayInitExpr = {
152
+ type: 'ArrayInitExpr';
153
+ operand?: ZigExpression;
154
+ elements: ZigExpression[];
155
+ };
156
+ export type ZigTryExpr = {
157
+ type: 'TryExpr';
158
+ operand: ZigExpression;
159
+ };
160
+ export type ZigComptimeExpr = {
161
+ type: 'ComptimeExpr';
162
+ operand: ZigExpression;
163
+ };
164
+ export type ZigBlockExpr = {
165
+ type: 'BlockExpr';
166
+ label?: string;
167
+ statements: ZigStatement[];
168
+ };
169
+ export type ZigGroupedExpr = {
170
+ type: 'GroupedExpr';
171
+ inner: ZigExpression;
172
+ };
173
+ export type ZigErrorSetExpr = {
174
+ type: 'ErrorSetExpr';
175
+ names: string[];
176
+ };
177
+ export type ZigStructExpr = {
178
+ type: 'StructExpr';
179
+ members: ZigContainerMember[];
180
+ };
181
+ export type ZigExpression = ZigIdentifier | ZigLiteral | ZigBinaryExpr | ZigUnaryExpr | ZigFieldAccessExpr | ZigIndexExpr | ZigSliceExpr | ZigCallExpr | ZigBuiltinCallExpr | ZigIfExpr | ZigSwitchExpr | ZigStructInitExpr | ZigArrayInitExpr | ZigTryExpr | ZigComptimeExpr | ZigBlockExpr | ZigGroupedExpr | ZigErrorSetExpr | ZigErrorUnionType | ZigPointerType | ZigOptionalType | ZigFnProtoType | ZigStructExpr | ZigArrayType;
182
+ export type ZigAssignOp = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=';
183
+ export type ZigAssignStmt = {
184
+ type: 'AssignStmt';
185
+ target: ZigExpression;
186
+ operator: ZigAssignOp;
187
+ value: ZigExpression;
188
+ };
189
+ export type ZigWhileStmt = {
190
+ type: 'WhileStmt';
191
+ condition: ZigExpression;
192
+ capture?: string;
193
+ continuation?: ZigExpression;
194
+ body: ZigStatement;
195
+ elseBody?: ZigStatement;
196
+ label?: string;
197
+ isInline: boolean;
198
+ };
199
+ export type ZigForStmt = {
200
+ type: 'ForStmt';
201
+ inputs: ZigExpression[];
202
+ captures: string[];
203
+ body: ZigStatement;
204
+ elseBody?: ZigStatement;
205
+ label?: string;
206
+ isInline: boolean;
207
+ };
208
+ export type ZigReturnStmt = {
209
+ type: 'ReturnStmt';
210
+ value?: ZigExpression;
211
+ };
212
+ export type ZigBreakStmt = {
213
+ type: 'BreakStmt';
214
+ label?: string;
215
+ value?: ZigExpression;
216
+ };
217
+ export type ZigContinueStmt = {
218
+ type: 'ContinueStmt';
219
+ label?: string;
220
+ };
221
+ export type ZigDeferStmt = {
222
+ type: 'DeferStmt';
223
+ isErrdefer: boolean;
224
+ capture?: string;
225
+ body: ZigStatement;
226
+ };
227
+ export type ZigStatement = ZigAssignStmt | ZigVarDecl | ZigWhileStmt | ZigForStmt | ZigReturnStmt | ZigBreakStmt | ZigContinueStmt | ZigDeferStmt | ZigExpression;
228
+ export type ZigFnParam = {
229
+ type: 'FnParam';
230
+ name?: string;
231
+ isComptime: boolean;
232
+ isNoalias: boolean;
233
+ typeExpr?: ZigTypeExpression;
234
+ };
235
+ export type ZigFnDecl = {
236
+ type: 'FnDecl';
237
+ isPub: boolean;
238
+ isExtern: boolean;
239
+ isExport: boolean;
240
+ isInline: boolean;
241
+ isComptime: boolean;
242
+ name: string;
243
+ params: ZigFnParam[];
244
+ returnType: ZigTypeExpression;
245
+ body?: ZigBlockExpr;
246
+ };
247
+ export type ZigVarDecl = {
248
+ type: 'VarDecl';
249
+ isConst: boolean;
250
+ isPub: boolean;
251
+ isExtern: boolean;
252
+ isComptime: boolean;
253
+ isThreadlocal: boolean;
254
+ name: string;
255
+ typeExpr?: ZigTypeExpression;
256
+ alignExpr?: ZigExpression;
257
+ initExpr?: ZigExpression;
258
+ };
259
+ export type ZigTestDecl = {
260
+ type: 'TestDecl';
261
+ name?: string;
262
+ body: ZigBlockExpr;
263
+ };
264
+ export type ZigUsingnamespaceDecl = {
265
+ type: 'UsingnamespaceDecl';
266
+ isPub: boolean;
267
+ expression: ZigExpression;
268
+ };
269
+ export type ZigContainerField = {
270
+ type: 'ContainerField';
271
+ name: string;
272
+ typeExpr?: ZigTypeExpression;
273
+ alignExpr?: ZigExpression;
274
+ defaultValue?: ZigExpression;
275
+ };
276
+ export type ZigContainerMember = ZigFnDecl | ZigVarDecl | ZigTestDecl | ZigUsingnamespaceDecl | ZigContainerField;
277
+ export type ZigRoot = {
278
+ type: 'Root';
279
+ members: ZigContainerMember[];
280
+ };
package/build/zig.js ADDED
@@ -0,0 +1,2 @@
1
+ // Zig AST type definitions
2
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type Parser } from './parser.js';
2
+ import { type ZigRoot } from './zig.js';
3
+ export declare const zigSourceFileParser: Parser<ZigRoot, string>;