Skip to content

Commit 487453f

Browse files
MirkoCovizzinordicjm
authored andcommitted
lib: at_parser: move generated code and ignore formatting
Moves the generated `at_match.c` to the `generated` directory and adds this directory to the excluded list for Checkpatch, so that the generated file does not require reformatting. This makes versioning easier since it removes the reformatting step necessary to comply with Checkpatch. Signed-off-by: Mirko Covizzi <mirko.covizzi@nordicsemi.no>
1 parent b60eb49 commit 487453f

File tree

4 files changed

+432
-507
lines changed

4 files changed

+432
-507
lines changed

.checkpatch.conf

+1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@
4949
--exclude doc/nrf/.*/.*/.*/images
5050
--exclude doc/nrf/.*/.*/.*/.*/images
5151
--exclude applications/nrf5340_audio/src/utils/macros
52+
--exclude lib/at_parser/generated
5253
--exclude lib/bin/lwm2m_carrier/include

lib/at_parser/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
zephyr_library()
88
zephyr_library_sources(
99
at_parser.c
10-
at_match.c
10+
generated/at_match.c
1111
)
1212

1313
zephyr_include_directories(include)

lib/at_parser/at_match.re

+155-160
Original file line numberDiff line numberDiff line change
@@ -4,87 +4,82 @@
44
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
*/
66

7-
/* at_match.c generated by re2c 3.0
7+
/* at_match.c generated by re2c 3.0-1
88
*
99
* Generated with:
10-
* re2c at_match.re -o at_match.c -W --no-debug-info --tags
11-
*
12-
* Reformatted with:
13-
* clang-format-15 -i at_match.c
14-
* Using the following additional .clangformat options:
15-
* IndentGotoLabels: false
16-
* SpaceBeforeInheritanceColon: False
10+
* re2c at_match.re -o generated/at_match.c -W --tags --no-debug-info --no-generation-date \
11+
* --no-version
1712
*/
1813

19-
#include "at_match.h"
14+
#include "../at_match.h"
2015

2116
struct at_token at_match_cmd(const char *at, const char **remainder)
2217
{
2318
const char *cursor = at;
2419
const char *marker = NULL;
2520

26-
/*!local:re2c
27-
re2c:define:YYCTYPE = "unsigned char";
28-
re2c:define:YYCURSOR = cursor;
29-
re2c:define:YYMARKER = marker;
30-
re2c:yyfill:enable = 0;
31-
32-
AT_CASE_INS = [Aa][Tt];
33-
CMD = [#%+][A-Za-z0-9]+;
34-
35-
cmd_test = AT_CASE_INS CMD "=?";
36-
cmd_read = AT_CASE_INS CMD "?";
37-
cmd_set = AT_CASE_INS CMD "=";
38-
cmd_set_no_subparams = AT_CASE_INS CMD?;
39-
notif = CMD ":";
40-
41-
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
42-
43-
cmd_test
44-
{
45-
if (remainder) *remainder = cursor;
46-
return (struct at_token){
47-
.start = at, .len = cursor - at - 2,
48-
.type = AT_TOKEN_TYPE_CMD_TEST
49-
};
50-
}
51-
52-
cmd_read
53-
{
54-
if (remainder) *remainder = cursor;
55-
return (struct at_token){
56-
.start = at, .len = cursor - at - 1,
57-
.type = AT_TOKEN_TYPE_CMD_READ
58-
};
59-
}
60-
61-
cmd_set
62-
{
63-
if (remainder) *remainder = cursor;
64-
return (struct at_token){
65-
.start = at, .len = cursor - at - 1,
66-
.type = AT_TOKEN_TYPE_CMD_SET
67-
};
68-
}
69-
70-
cmd_set_no_subparams
71-
{
72-
if (remainder) *remainder = cursor;
73-
return (struct at_token){
74-
.start = at, .len = cursor - at,
75-
.type = AT_TOKEN_TYPE_CMD_SET
76-
};
77-
}
78-
79-
notif
80-
{
81-
if (remainder) *remainder = cursor;
82-
return (struct at_token){
83-
.start = at, .len = cursor - at - 1,
84-
.type = AT_TOKEN_TYPE_NOTIF
85-
};
86-
}
87-
*/
21+
/*!local:re2c
22+
re2c:define:YYCTYPE = "unsigned char";
23+
re2c:define:YYCURSOR = cursor;
24+
re2c:define:YYMARKER = marker;
25+
re2c:yyfill:enable = 0;
26+
27+
AT_CASE_INS = [Aa][Tt];
28+
CMD = [#%+][A-Za-z0-9]+;
29+
30+
cmd_test = AT_CASE_INS CMD "=?";
31+
cmd_read = AT_CASE_INS CMD "?";
32+
cmd_set = AT_CASE_INS CMD "=";
33+
cmd_set_no_subparams = AT_CASE_INS CMD?;
34+
notif = CMD ":";
35+
36+
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
37+
38+
cmd_test
39+
{
40+
if (remainder) *remainder = cursor;
41+
return (struct at_token){
42+
.start = at, .len = cursor - at - 2,
43+
.type = AT_TOKEN_TYPE_CMD_TEST
44+
};
45+
}
46+
47+
cmd_read
48+
{
49+
if (remainder) *remainder = cursor;
50+
return (struct at_token){
51+
.start = at, .len = cursor - at - 1,
52+
.type = AT_TOKEN_TYPE_CMD_READ
53+
};
54+
}
55+
56+
cmd_set
57+
{
58+
if (remainder) *remainder = cursor;
59+
return (struct at_token){
60+
.start = at, .len = cursor - at - 1,
61+
.type = AT_TOKEN_TYPE_CMD_SET
62+
};
63+
}
64+
65+
cmd_set_no_subparams
66+
{
67+
if (remainder) *remainder = cursor;
68+
return (struct at_token){
69+
.start = at, .len = cursor - at,
70+
.type = AT_TOKEN_TYPE_CMD_SET
71+
};
72+
}
73+
74+
notif
75+
{
76+
if (remainder) *remainder = cursor;
77+
return (struct at_token){
78+
.start = at, .len = cursor - at - 1,
79+
.type = AT_TOKEN_TYPE_NOTIF
80+
};
81+
}
82+
*/
8883
}
8984

9085
struct at_token at_match_subparam(const char *at, const char **remainder)
@@ -94,75 +89,75 @@ struct at_token at_match_subparam(const char *at, const char **remainder)
9489
const char *t1;
9590
const char *t2;
9691

97-
/*!stags:re2c format = 'const char *@@;\n'; */
98-
99-
/*!local:re2c
100-
re2c:define:YYCTYPE = "unsigned char";
101-
re2c:define:YYCURSOR = cursor;
102-
re2c:define:YYMARKER = marker;
103-
re2c:yyfill:enable = 0;
104-
105-
SPACE = " ";
106-
INT = "0"|[+\-]?[1-9][0-9]*;
107-
COMMA = ",";
108-
QUOTE = "\"";
109-
QUOTED_STR = QUOTE @t1 [^"\x00]* @t2 QUOTE;
110-
OPEN_PAR = "(";
111-
CLOSE_PAR = ")";
112-
ARRAY = OPEN_PAR [^()\x00]+ CLOSE_PAR;
113-
114-
int = SPACE? @t1 INT @t2 COMMA?;
115-
quoted_str = SPACE? QUOTED_STR COMMA?;
116-
array = SPACE? @t1 ARRAY @t2 COMMA?;
117-
empty = SPACE? @t1 @t2 COMMA;
118-
119-
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
120-
121-
int
122-
{
123-
char last = *(cursor - 1);
124-
125-
if (remainder) *remainder = cursor;
126-
return (struct at_token){
127-
.start = t1, .len = t2 - t1,
128-
.type = AT_TOKEN_TYPE_INT,
129-
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
130-
};
131-
}
132-
133-
quoted_str
134-
{
135-
char last = *(cursor - 1);
136-
137-
if (remainder) *remainder = cursor;
138-
return (struct at_token){
139-
.start = t1, .len = t2 - t1,
140-
.type = AT_TOKEN_TYPE_QUOTED_STRING,
141-
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
142-
};
143-
}
144-
145-
array
146-
{
147-
char last = *(cursor - 1);
148-
149-
if (remainder) *remainder = cursor;
150-
return (struct at_token){
151-
.start = t1, .len = t2 - t1,
152-
.type = AT_TOKEN_TYPE_ARRAY,
153-
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
154-
};
155-
}
156-
157-
empty
158-
{
159-
if (remainder) *remainder = cursor;
160-
return (struct at_token){
161-
.start = t1, .len = t2 - t1,
162-
.type = AT_TOKEN_TYPE_EMPTY, .var = AT_TOKEN_VAR_COMMA
163-
};
164-
}
165-
*/
92+
/*!stags:re2c format = 'const char *@@;'; */
93+
94+
/*!local:re2c
95+
re2c:define:YYCTYPE = "unsigned char";
96+
re2c:define:YYCURSOR = cursor;
97+
re2c:define:YYMARKER = marker;
98+
re2c:yyfill:enable = 0;
99+
100+
SPACE = " ";
101+
INT = "0"|[+\-]?[1-9][0-9]*;
102+
COMMA = ",";
103+
QUOTE = "\"";
104+
QUOTED_STR = QUOTE @t1 [^"\x00]* @t2 QUOTE;
105+
OPEN_PAR = "(";
106+
CLOSE_PAR = ")";
107+
ARRAY = OPEN_PAR [^()\x00]+ CLOSE_PAR;
108+
109+
int = SPACE? @t1 INT @t2 COMMA?;
110+
quoted_str = SPACE? QUOTED_STR COMMA?;
111+
array = SPACE? @t1 ARRAY @t2 COMMA?;
112+
empty = SPACE? @t1 @t2 COMMA;
113+
114+
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
115+
116+
int
117+
{
118+
char last = *(cursor - 1);
119+
120+
if (remainder) *remainder = cursor;
121+
return (struct at_token){
122+
.start = t1, .len = t2 - t1,
123+
.type = AT_TOKEN_TYPE_INT,
124+
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
125+
};
126+
}
127+
128+
quoted_str
129+
{
130+
char last = *(cursor - 1);
131+
132+
if (remainder) *remainder = cursor;
133+
return (struct at_token){
134+
.start = t1, .len = t2 - t1,
135+
.type = AT_TOKEN_TYPE_QUOTED_STRING,
136+
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
137+
};
138+
}
139+
140+
array
141+
{
142+
char last = *(cursor - 1);
143+
144+
if (remainder) *remainder = cursor;
145+
return (struct at_token){
146+
.start = t1, .len = t2 - t1,
147+
.type = AT_TOKEN_TYPE_ARRAY,
148+
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
149+
};
150+
}
151+
152+
empty
153+
{
154+
if (remainder) *remainder = cursor;
155+
return (struct at_token){
156+
.start = t1, .len = t2 - t1,
157+
.type = AT_TOKEN_TYPE_EMPTY, .var = AT_TOKEN_VAR_COMMA
158+
};
159+
}
160+
*/
166161
}
167162

168163
struct at_token at_match_str(const char *at, const char **remainder)
@@ -172,29 +167,29 @@ struct at_token at_match_str(const char *at, const char **remainder)
172167
const char *t1;
173168
const char *t2;
174169

175-
/*!stags:re2c format = 'const char *@@;\n'; */
170+
/*!stags:re2c format = 'const char *@@;'; */
176171

177-
/*!local:re2c
178-
re2c:define:YYCTYPE = "unsigned char";
179-
re2c:define:YYCURSOR = cursor;
180-
re2c:define:YYMARKER = marker;
181-
re2c:yyfill:enable = 0;
172+
/*!local:re2c
173+
re2c:define:YYCTYPE = "unsigned char";
174+
re2c:define:YYCURSOR = cursor;
175+
re2c:define:YYMARKER = marker;
176+
re2c:yyfill:enable = 0;
182177
183-
SPACE = " ";
184-
CRLF = "\r\n";
185-
STR = [A-Za-z0-9][A-Za-z_\-.0-9 ]*;
178+
SPACE = " ";
179+
CRLF = "\r\n";
180+
STR = [A-Za-z0-9][A-Za-z_\-.0-9 ]*;
186181
187-
str = SPACE? @t1 STR @t2 CRLF?;
182+
str = SPACE? @t1 STR @t2 CRLF?;
188183
189-
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
184+
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
190185
191-
str
192-
{
193-
if (remainder) *remainder = t2;
194-
return (struct at_token){
195-
.start = t1, .len = t2 - t1,
196-
.type = AT_TOKEN_TYPE_STRING,
197-
};
198-
}
199-
*/
186+
str
187+
{
188+
if (remainder) *remainder = t2;
189+
return (struct at_token){
190+
.start = t1, .len = t2 - t1,
191+
.type = AT_TOKEN_TYPE_STRING,
192+
};
193+
}
194+
*/
200195
}

0 commit comments

Comments
 (0)