c-next 0.2.17 → 0.2.18
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.
- package/README.md +2 -2
- package/dist/index.js +7645 -5941
- package/dist/index.js.map +4 -4
- package/grammar/CNext.g4 +8 -0
- package/package.json +1 -3
- package/src/transpiler/Transpiler.ts +286 -26
- package/src/transpiler/__tests__/compileCommandsDiscovery.integration.test.ts +94 -0
- package/src/transpiler/__tests__/externalSymbolRecovery.integration.test.ts +215 -0
- package/src/transpiler/logic/__tests__/detectAssemblySyntax.test.ts +116 -0
- package/src/transpiler/logic/analysis/FunctionCallAnalyzer.ts +8 -0
- package/src/transpiler/logic/analysis/MixedTypeCategoryAnalyzer.ts +408 -0
- package/src/transpiler/logic/analysis/PassByValueAnalyzer.ts +16 -97
- package/src/transpiler/logic/analysis/ReturnPathAnalyzer.ts +171 -0
- package/src/transpiler/logic/analysis/__tests__/MixedTypeCategoryAnalyzer.test.ts +346 -0
- package/src/transpiler/logic/analysis/__tests__/ReturnPathAnalyzer.test.ts +232 -0
- package/src/transpiler/logic/analysis/runAnalyzers.ts +23 -2
- package/src/transpiler/logic/analysis/types/IMixedTypeCategoryError.ts +17 -0
- package/src/transpiler/logic/analysis/types/IReturnPathError.ts +12 -0
- package/src/transpiler/logic/detectAssemblySyntax.ts +80 -0
- package/src/transpiler/logic/parser/grammar/CNext.interp +4 -1
- package/src/transpiler/logic/parser/grammar/CNext.tokens +169 -167
- package/src/transpiler/logic/parser/grammar/CNextLexer.interp +4 -1
- package/src/transpiler/logic/parser/grammar/CNextLexer.tokens +169 -167
- package/src/transpiler/logic/parser/grammar/CNextLexer.ts +545 -541
- package/src/transpiler/logic/parser/grammar/CNextListener.ts +11 -0
- package/src/transpiler/logic/parser/grammar/CNextParser.ts +1257 -1185
- package/src/transpiler/logic/parser/grammar/CNextVisitor.ts +7 -0
- package/src/transpiler/logic/preprocessor/CompileCommandsReader.ts +332 -0
- package/src/transpiler/logic/preprocessor/ExternalDeclarationOracle.ts +202 -0
- package/src/transpiler/logic/preprocessor/Preprocessor.ts +24 -6
- package/src/transpiler/logic/preprocessor/ToolchainDetector.ts +42 -1
- package/src/transpiler/logic/preprocessor/__tests__/CompileCommandsReader.test.ts +216 -0
- package/src/transpiler/logic/preprocessor/__tests__/ExternalDeclarationOracle.test.ts +153 -0
- package/src/transpiler/logic/preprocessor/__tests__/Preprocessor.test.ts +43 -18
- package/src/transpiler/logic/preprocessor/__tests__/ToolchainDetector.crossCompiler.test.ts +75 -0
- package/src/transpiler/logic/preprocessor/__tests__/fixtures/oracle/dependent.h +7 -0
- package/src/transpiler/logic/preprocessor/__tests__/fixtures/oracle/predecessor.h +5 -0
- package/src/transpiler/logic/preprocessor/types/ICompileCommandsResult.ts +14 -0
- package/src/transpiler/logic/preprocessor/types/IPreprocessOptions.ts +17 -0
- package/src/transpiler/logic/symbols/SymbolTable.ts +45 -0
- package/src/transpiler/logic/symbols/__tests__/SymbolTable.test.ts +49 -0
- package/src/transpiler/output/MisraSuppressionUtils.ts +52 -0
- package/src/transpiler/output/__tests__/MisraSuppressionUtils.test.ts +67 -0
- package/src/transpiler/output/codegen/CodeGenerator.ts +45 -4
- package/src/transpiler/output/codegen/TypeResolver.ts +148 -0
- package/src/transpiler/output/codegen/TypeValidator.ts +179 -81
- package/src/transpiler/output/codegen/__tests__/CodeGenerator.test.ts +13 -1
- package/src/transpiler/output/codegen/__tests__/TypeResolver.test.ts +93 -0
- package/src/transpiler/output/codegen/__tests__/TypeValidator.alwaysTrueLoop.test.ts +91 -0
- package/src/transpiler/output/codegen/__tests__/TypeValidator.test.ts +86 -14
- package/src/transpiler/output/codegen/assignment/AssignmentClassifier.ts +13 -0
- package/src/transpiler/output/codegen/assignment/AssignmentKind.ts +1 -1
- package/src/transpiler/output/codegen/assignment/handlers/AccessPatternHandlers.ts +20 -12
- package/src/transpiler/output/codegen/assignment/handlers/ArrayHandlers.ts +424 -22
- package/src/transpiler/output/codegen/assignment/handlers/BitAccessHandlers.ts +31 -18
- package/src/transpiler/output/codegen/assignment/handlers/BitmapHandlers.ts +7 -8
- package/src/transpiler/output/codegen/assignment/handlers/RegisterHandlers.ts +6 -8
- package/src/transpiler/output/codegen/assignment/handlers/RegisterUtils.ts +12 -10
- package/src/transpiler/output/codegen/assignment/handlers/SimpleHandler.ts +3 -7
- package/src/transpiler/output/codegen/assignment/handlers/SpecialHandlers.ts +7 -9
- package/src/transpiler/output/codegen/assignment/handlers/StringHandlers.ts +12 -10
- package/src/transpiler/output/codegen/assignment/handlers/__tests__/ArrayHandlers.test.ts +479 -11
- package/src/transpiler/output/codegen/generators/IOrchestrator.ts +3 -0
- package/src/transpiler/output/codegen/generators/expressions/CallExprGenerator.ts +28 -15
- package/src/transpiler/output/codegen/generators/expressions/PostfixExpressionGenerator.ts +26 -13
- package/src/transpiler/output/codegen/generators/expressions/__tests__/PostfixExpressionGenerator.test.ts +129 -1
- package/src/transpiler/output/codegen/generators/statements/ControlFlowGenerator.ts +64 -8
- package/src/transpiler/output/codegen/generators/statements/__tests__/ControlFlowGenerator.test.ts +8 -5
- package/src/transpiler/output/codegen/helpers/AssignmentExpectedTypeResolver.ts +30 -2
- package/src/transpiler/output/codegen/helpers/StringDeclHelper.ts +16 -13
- package/src/transpiler/output/codegen/helpers/__tests__/AssignmentExpectedTypeResolver.test.ts +19 -0
- package/src/transpiler/output/codegen/helpers/__tests__/StringDeclHelper.test.ts +57 -11
- package/src/transpiler/output/codegen/subscript/SubscriptClassifier.ts +30 -11
- package/src/transpiler/output/codegen/subscript/TSubscriptKind.ts +1 -1
- package/src/transpiler/output/codegen/subscript/__tests__/SubscriptClassifier.test.ts +38 -6
- package/src/transpiler/output/headers/HeaderGeneratorUtils.ts +65 -24
- package/src/transpiler/state/CodeGenState.ts +20 -16
- package/src/transpiler/types/ICachedFileEntry.ts +7 -0
- package/src/utils/cache/CacheManager.ts +13 -2
- package/src/utils/cache/__tests__/CacheManager.test.ts +18 -1
- package/src/utils/constants/TypeConstants.ts +13 -0
|
@@ -24,97 +24,98 @@ ELSE=23
|
|
|
24
24
|
WHILE=24
|
|
25
25
|
DO=25
|
|
26
26
|
FOR=26
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
27
|
+
FOREVER=27
|
|
28
|
+
SWITCH=28
|
|
29
|
+
CASE=29
|
|
30
|
+
DEFAULT=30
|
|
31
|
+
RETURN=31
|
|
32
|
+
TRUE=32
|
|
33
|
+
FALSE=33
|
|
34
|
+
C_NULL=34
|
|
35
|
+
STRING=35
|
|
36
|
+
SIZEOF=36
|
|
37
|
+
BITMAP8=37
|
|
38
|
+
BITMAP16=38
|
|
39
|
+
BITMAP24=39
|
|
40
|
+
BITMAP32=40
|
|
41
|
+
RW=41
|
|
42
|
+
RO=42
|
|
43
|
+
WO=43
|
|
44
|
+
W1C=44
|
|
45
|
+
W1S=45
|
|
46
|
+
CLAMP=46
|
|
47
|
+
WRAP=47
|
|
48
|
+
ATOMIC=48
|
|
49
|
+
CRITICAL=49
|
|
50
|
+
SUFFIXED_FLOAT=50
|
|
51
|
+
SUFFIXED_HEX=51
|
|
52
|
+
SUFFIXED_BINARY=52
|
|
53
|
+
SUFFIXED_DECIMAL=53
|
|
54
|
+
U8=54
|
|
55
|
+
U16=55
|
|
56
|
+
U32=56
|
|
57
|
+
U64=57
|
|
58
|
+
I8=58
|
|
59
|
+
I16=59
|
|
60
|
+
I32=60
|
|
61
|
+
I64=61
|
|
62
|
+
F32=62
|
|
63
|
+
F64=63
|
|
64
|
+
BOOL=64
|
|
65
|
+
ISR_TYPE=65
|
|
66
|
+
LSHIFT_ASSIGN=66
|
|
67
|
+
RSHIFT_ASSIGN=67
|
|
68
|
+
PLUS_ASSIGN=68
|
|
69
|
+
MINUS_ASSIGN=69
|
|
70
|
+
STAR_ASSIGN=70
|
|
71
|
+
SLASH_ASSIGN=71
|
|
72
|
+
PERCENT_ASSIGN=72
|
|
73
|
+
BITAND_ASSIGN=73
|
|
74
|
+
BITOR_ASSIGN=74
|
|
75
|
+
BITXOR_ASSIGN=75
|
|
76
|
+
ASSIGN=76
|
|
77
|
+
EQ=77
|
|
78
|
+
NEQ=78
|
|
79
|
+
LT=79
|
|
80
|
+
GT=80
|
|
81
|
+
LTE=81
|
|
82
|
+
GTE=82
|
|
83
|
+
PLUS=83
|
|
84
|
+
MINUS=84
|
|
85
|
+
STAR=85
|
|
86
|
+
SLASH=86
|
|
87
|
+
PERCENT=87
|
|
88
|
+
AND=88
|
|
89
|
+
OR=89
|
|
90
|
+
NOT=90
|
|
91
|
+
BITAND=91
|
|
92
|
+
BITOR=92
|
|
93
|
+
BITXOR=93
|
|
94
|
+
BITNOT=94
|
|
95
|
+
LSHIFT=95
|
|
96
|
+
RSHIFT=96
|
|
97
|
+
LPAREN=97
|
|
98
|
+
RPAREN=98
|
|
99
|
+
LBRACE=99
|
|
100
|
+
RBRACE=100
|
|
101
|
+
LBRACKET=101
|
|
102
|
+
RBRACKET=102
|
|
103
|
+
SEMI=103
|
|
104
|
+
COMMA=104
|
|
105
|
+
DOT=105
|
|
106
|
+
AT=106
|
|
107
|
+
COLON=107
|
|
108
|
+
HEX_LITERAL=108
|
|
109
|
+
BINARY_LITERAL=109
|
|
110
|
+
FLOAT_LITERAL=110
|
|
111
|
+
INTEGER_LITERAL=111
|
|
112
|
+
STRING_LITERAL=112
|
|
113
|
+
CHAR_LITERAL=113
|
|
114
|
+
IDENTIFIER=114
|
|
115
|
+
DOC_COMMENT=115
|
|
116
|
+
LINE_COMMENT=116
|
|
117
|
+
BLOCK_COMMENT=117
|
|
118
|
+
WS=118
|
|
118
119
|
'?'=1
|
|
119
120
|
'scope'=11
|
|
120
121
|
'struct'=12
|
|
@@ -132,79 +133,80 @@ WS=117
|
|
|
132
133
|
'while'=24
|
|
133
134
|
'do'=25
|
|
134
135
|
'for'=26
|
|
135
|
-
'
|
|
136
|
-
'
|
|
137
|
-
'
|
|
138
|
-
'
|
|
139
|
-
'
|
|
140
|
-
'
|
|
141
|
-
'
|
|
142
|
-
'
|
|
143
|
-
'
|
|
144
|
-
'
|
|
145
|
-
'
|
|
146
|
-
'
|
|
147
|
-
'
|
|
148
|
-
'
|
|
149
|
-
'
|
|
150
|
-
'
|
|
151
|
-
'
|
|
152
|
-
'
|
|
153
|
-
'
|
|
154
|
-
'
|
|
155
|
-
'
|
|
156
|
-
'
|
|
157
|
-
'
|
|
158
|
-
'
|
|
159
|
-
'
|
|
160
|
-
'
|
|
161
|
-
'
|
|
162
|
-
'
|
|
163
|
-
'
|
|
164
|
-
'
|
|
165
|
-
'
|
|
166
|
-
'
|
|
167
|
-
'
|
|
168
|
-
'
|
|
169
|
-
'
|
|
170
|
-
'
|
|
171
|
-
'
|
|
172
|
-
'
|
|
173
|
-
'
|
|
174
|
-
'
|
|
175
|
-
'
|
|
176
|
-
'
|
|
177
|
-
'
|
|
178
|
-
'
|
|
179
|
-
'
|
|
180
|
-
'
|
|
181
|
-
'
|
|
182
|
-
'
|
|
183
|
-
'
|
|
184
|
-
'
|
|
185
|
-
'
|
|
186
|
-
'
|
|
187
|
-
'
|
|
188
|
-
'
|
|
189
|
-
'
|
|
190
|
-
'
|
|
191
|
-
'
|
|
192
|
-
'
|
|
193
|
-
'
|
|
194
|
-
'
|
|
195
|
-
'
|
|
196
|
-
'
|
|
197
|
-
'
|
|
198
|
-
'
|
|
199
|
-
'
|
|
200
|
-
'
|
|
201
|
-
'
|
|
202
|
-
'
|
|
203
|
-
'
|
|
204
|
-
'
|
|
205
|
-
'
|
|
206
|
-
'
|
|
207
|
-
'
|
|
208
|
-
'
|
|
209
|
-
'
|
|
210
|
-
'
|
|
136
|
+
'forever'=27
|
|
137
|
+
'switch'=28
|
|
138
|
+
'case'=29
|
|
139
|
+
'default'=30
|
|
140
|
+
'return'=31
|
|
141
|
+
'true'=32
|
|
142
|
+
'false'=33
|
|
143
|
+
'NULL'=34
|
|
144
|
+
'string'=35
|
|
145
|
+
'sizeof'=36
|
|
146
|
+
'bitmap8'=37
|
|
147
|
+
'bitmap16'=38
|
|
148
|
+
'bitmap24'=39
|
|
149
|
+
'bitmap32'=40
|
|
150
|
+
'rw'=41
|
|
151
|
+
'ro'=42
|
|
152
|
+
'wo'=43
|
|
153
|
+
'w1c'=44
|
|
154
|
+
'w1s'=45
|
|
155
|
+
'clamp'=46
|
|
156
|
+
'wrap'=47
|
|
157
|
+
'atomic'=48
|
|
158
|
+
'critical'=49
|
|
159
|
+
'u8'=54
|
|
160
|
+
'u16'=55
|
|
161
|
+
'u32'=56
|
|
162
|
+
'u64'=57
|
|
163
|
+
'i8'=58
|
|
164
|
+
'i16'=59
|
|
165
|
+
'i32'=60
|
|
166
|
+
'i64'=61
|
|
167
|
+
'f32'=62
|
|
168
|
+
'f64'=63
|
|
169
|
+
'bool'=64
|
|
170
|
+
'ISR'=65
|
|
171
|
+
'<<<-'=66
|
|
172
|
+
'>><-'=67
|
|
173
|
+
'+<-'=68
|
|
174
|
+
'-<-'=69
|
|
175
|
+
'*<-'=70
|
|
176
|
+
'/<-'=71
|
|
177
|
+
'%<-'=72
|
|
178
|
+
'&<-'=73
|
|
179
|
+
'|<-'=74
|
|
180
|
+
'^<-'=75
|
|
181
|
+
'<-'=76
|
|
182
|
+
'='=77
|
|
183
|
+
'!='=78
|
|
184
|
+
'<'=79
|
|
185
|
+
'>'=80
|
|
186
|
+
'<='=81
|
|
187
|
+
'>='=82
|
|
188
|
+
'+'=83
|
|
189
|
+
'-'=84
|
|
190
|
+
'*'=85
|
|
191
|
+
'/'=86
|
|
192
|
+
'%'=87
|
|
193
|
+
'&&'=88
|
|
194
|
+
'||'=89
|
|
195
|
+
'!'=90
|
|
196
|
+
'&'=91
|
|
197
|
+
'|'=92
|
|
198
|
+
'^'=93
|
|
199
|
+
'~'=94
|
|
200
|
+
'<<'=95
|
|
201
|
+
'>>'=96
|
|
202
|
+
'('=97
|
|
203
|
+
')'=98
|
|
204
|
+
'{'=99
|
|
205
|
+
'}'=100
|
|
206
|
+
'['=101
|
|
207
|
+
']'=102
|
|
208
|
+
';'=103
|
|
209
|
+
','=104
|
|
210
|
+
'.'=105
|
|
211
|
+
'@'=106
|
|
212
|
+
':'=107
|