Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: at_parser: move generated code, ignore formatting #17014

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
MirkoCovizzi committed Aug 26, 2024
commit 9e902dd810b84714c906a25fc73e85e1847d2182
1 change: 1 addition & 0 deletions .checkpatch.conf
Original file line number Diff line number Diff line change
@@ -49,4 +49,5 @@
--exclude doc/nrf/.*/.*/.*/images
--exclude doc/nrf/.*/.*/.*/.*/images
--exclude applications/nrf5340_audio/src/utils/macros
--exclude lib/at_parser/generated
--exclude lib/bin/lwm2m_carrier/include
2 changes: 1 addition & 1 deletion lib/at_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
zephyr_library()
zephyr_library_sources(
at_parser.c
at_match.c
generated/at_match.c
)

zephyr_include_directories(include)
315 changes: 155 additions & 160 deletions lib/at_parser/at_match.re
Original file line number Diff line number Diff line change
@@ -4,87 +4,82 @@
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/* at_match.c generated by re2c 3.0
/* at_match.c generated by re2c 3.0-1
*
* Generated with:
* re2c at_match.re -o at_match.c -W --no-debug-info --tags
*
* Reformatted with:
* clang-format-15 -i at_match.c
* Using the following additional .clangformat options:
* IndentGotoLabels: false
* SpaceBeforeInheritanceColon: False
* re2c at_match.re -o generated/at_match.c -W --tags --no-debug-info --no-generation-date \
* --no-version
*/

#include "at_match.h"
#include "../at_match.h"

struct at_token at_match_cmd(const char *at, const char **remainder)
{
const char *cursor = at;
const char *marker = NULL;

/*!local:re2c
re2c:define:YYCTYPE = "unsigned char";
re2c:define:YYCURSOR = cursor;
re2c:define:YYMARKER = marker;
re2c:yyfill:enable = 0;
AT_CASE_INS = [Aa][Tt];
CMD = [#%+][A-Za-z0-9]+;
cmd_test = AT_CASE_INS CMD "=?";
cmd_read = AT_CASE_INS CMD "?";
cmd_set = AT_CASE_INS CMD "=";
cmd_set_no_subparams = AT_CASE_INS CMD?;
notif = CMD ":";
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
cmd_test
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = at, .len = cursor - at - 2,
.type = AT_TOKEN_TYPE_CMD_TEST
};
}
cmd_read
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = at, .len = cursor - at - 1,
.type = AT_TOKEN_TYPE_CMD_READ
};
}
cmd_set
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = at, .len = cursor - at - 1,
.type = AT_TOKEN_TYPE_CMD_SET
};
}
cmd_set_no_subparams
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = at, .len = cursor - at,
.type = AT_TOKEN_TYPE_CMD_SET
};
}
notif
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = at, .len = cursor - at - 1,
.type = AT_TOKEN_TYPE_NOTIF
};
}
*/
/*!local:re2c
re2c:define:YYCTYPE = "unsigned char";
re2c:define:YYCURSOR = cursor;
re2c:define:YYMARKER = marker;
re2c:yyfill:enable = 0;
AT_CASE_INS = [Aa][Tt];
CMD = [#%+][A-Za-z0-9]+;
cmd_test = AT_CASE_INS CMD "=?";
cmd_read = AT_CASE_INS CMD "?";
cmd_set = AT_CASE_INS CMD "=";
cmd_set_no_subparams = AT_CASE_INS CMD?;
notif = CMD ":";
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
cmd_test
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = at, .len = cursor - at - 2,
.type = AT_TOKEN_TYPE_CMD_TEST
};
}
cmd_read
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = at, .len = cursor - at - 1,
.type = AT_TOKEN_TYPE_CMD_READ
};
}
cmd_set
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = at, .len = cursor - at - 1,
.type = AT_TOKEN_TYPE_CMD_SET
};
}
cmd_set_no_subparams
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = at, .len = cursor - at,
.type = AT_TOKEN_TYPE_CMD_SET
};
}
notif
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = at, .len = cursor - at - 1,
.type = AT_TOKEN_TYPE_NOTIF
};
}
*/
}

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)
const char *t1;
const char *t2;

/*!stags:re2c format = 'const char *@@;\n'; */

/*!local:re2c
re2c:define:YYCTYPE = "unsigned char";
re2c:define:YYCURSOR = cursor;
re2c:define:YYMARKER = marker;
re2c:yyfill:enable = 0;
SPACE = " ";
INT = "0"|[+\-]?[1-9][0-9]*;
COMMA = ",";
QUOTE = "\"";
QUOTED_STR = QUOTE @t1 [^"\x00]* @t2 QUOTE;
OPEN_PAR = "(";
CLOSE_PAR = ")";
ARRAY = OPEN_PAR [^()\x00]+ CLOSE_PAR;
int = SPACE? @t1 INT @t2 COMMA?;
quoted_str = SPACE? QUOTED_STR COMMA?;
array = SPACE? @t1 ARRAY @t2 COMMA?;
empty = SPACE? @t1 @t2 COMMA;
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
int
{
char last = *(cursor - 1);
if (remainder) *remainder = cursor;
return (struct at_token){
.start = t1, .len = t2 - t1,
.type = AT_TOKEN_TYPE_INT,
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
};
}
quoted_str
{
char last = *(cursor - 1);
if (remainder) *remainder = cursor;
return (struct at_token){
.start = t1, .len = t2 - t1,
.type = AT_TOKEN_TYPE_QUOTED_STRING,
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
};
}
array
{
char last = *(cursor - 1);
if (remainder) *remainder = cursor;
return (struct at_token){
.start = t1, .len = t2 - t1,
.type = AT_TOKEN_TYPE_ARRAY,
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
};
}
empty
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = t1, .len = t2 - t1,
.type = AT_TOKEN_TYPE_EMPTY, .var = AT_TOKEN_VAR_COMMA
};
}
*/
/*!stags:re2c format = 'const char *@@;'; */

/*!local:re2c
re2c:define:YYCTYPE = "unsigned char";
re2c:define:YYCURSOR = cursor;
re2c:define:YYMARKER = marker;
re2c:yyfill:enable = 0;
SPACE = " ";
INT = "0"|[+\-]?[1-9][0-9]*;
COMMA = ",";
QUOTE = "\"";
QUOTED_STR = QUOTE @t1 [^"\x00]* @t2 QUOTE;
OPEN_PAR = "(";
CLOSE_PAR = ")";
ARRAY = OPEN_PAR [^()\x00]+ CLOSE_PAR;
int = SPACE? @t1 INT @t2 COMMA?;
quoted_str = SPACE? QUOTED_STR COMMA?;
array = SPACE? @t1 ARRAY @t2 COMMA?;
empty = SPACE? @t1 @t2 COMMA;
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
int
{
char last = *(cursor - 1);
if (remainder) *remainder = cursor;
return (struct at_token){
.start = t1, .len = t2 - t1,
.type = AT_TOKEN_TYPE_INT,
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
};
}
quoted_str
{
char last = *(cursor - 1);
if (remainder) *remainder = cursor;
return (struct at_token){
.start = t1, .len = t2 - t1,
.type = AT_TOKEN_TYPE_QUOTED_STRING,
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
};
}
array
{
char last = *(cursor - 1);
if (remainder) *remainder = cursor;
return (struct at_token){
.start = t1, .len = t2 - t1,
.type = AT_TOKEN_TYPE_ARRAY,
.var = last == ',' ? AT_TOKEN_VAR_COMMA : AT_TOKEN_VAR_NO_COMMA
};
}
empty
{
if (remainder) *remainder = cursor;
return (struct at_token){
.start = t1, .len = t2 - t1,
.type = AT_TOKEN_TYPE_EMPTY, .var = AT_TOKEN_VAR_COMMA
};
}
*/
}

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)
const char *t1;
const char *t2;

/*!stags:re2c format = 'const char *@@;\n'; */
/*!stags:re2c format = 'const char *@@;'; */

/*!local:re2c
re2c:define:YYCTYPE = "unsigned char";
re2c:define:YYCURSOR = cursor;
re2c:define:YYMARKER = marker;
re2c:yyfill:enable = 0;
/*!local:re2c
re2c:define:YYCTYPE = "unsigned char";
re2c:define:YYCURSOR = cursor;
re2c:define:YYMARKER = marker;
re2c:yyfill:enable = 0;
SPACE = " ";
CRLF = "\r\n";
STR = [A-Za-z0-9][A-Za-z_\-.0-9 ]*;
SPACE = " ";
CRLF = "\r\n";
STR = [A-Za-z0-9][A-Za-z_\-.0-9 ]*;
str = SPACE? @t1 STR @t2 CRLF?;
str = SPACE? @t1 STR @t2 CRLF?;
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
* { return (struct at_token){ .type = AT_TOKEN_TYPE_INVALID }; }
str
{
if (remainder) *remainder = t2;
return (struct at_token){
.start = t1, .len = t2 - t1,
.type = AT_TOKEN_TYPE_STRING,
};
}
*/
str
{
if (remainder) *remainder = t2;
return (struct at_token){
.start = t1, .len = t2 - t1,
.type = AT_TOKEN_TYPE_STRING,
};
}
*/
}
621 changes: 275 additions & 346 deletions lib/at_parser/at_match.c → lib/at_parser/generated/at_match.c

Large diffs are not rendered by default.