// /*
// * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved.
// */
// #ifndef TRE_H
// #define TRE_H
// extern double AddNumbers(const double f1, const double f2);
// #endif
/*
* Copyright (c) Shenzhen Yinwang Intelligent Technologies Co., Ltd. 2024. All rights reserved.
* Description: Public Domain Tiny Regular Expressions Library
* Author: Zhao Quan z00809758
* Date: 2023-7-13 10:33:55
*/
// Public Domain Tiny Regular Expressions Library
// Forked from https://github.com/kokke/tiny-regex-c
//
// Supports:
// ---------
// '^' Start anchor, matches start of string
// '$' End anchor, matches end of string
// ---------
// '*' Asterisk, match zero or more (greedy, *? lazy)
// '+' Plus, match one or more (greedy, +? lazy)
// '{m,n}' Quantifier, match min. 'm' and max. 'n' (greedy, {m,n}? lazy)
// '{m}' exactly 'm'
// '{m,}' match min 'm' and max. MAX_QUANT
// '?' Question, match zero or one (greedy, ?? lazy)
// ---------
// '.' Dot, matches any character except newline (\r, \n)
// '[abc]' Character class, match if one of {'a', 'b', 'c'}
// '[^abc]' Inverted class, match if NOT one of {'a', 'b', 'c'}
// '[a-zA-Z]' Character ranges, the character set of the ranges { a-z | A-Z }
// '\s' Whitespace, \t \f \r \n \v and spaces
// '\S' Non-whitespace
// '\w' Alphanumeric, [a-zA-Z0-9_]
// '\W' Non-alphanumeric
// '\d' Digits, [0-9]
// '\D' Non-digits
// '\X' Character itself; X in [^sSwWdD] (e.g. '\\' is '\')
// ---------
#ifndef TRE_H_INCLUDE
#define TRE_H_INCLUDE
#ifndef TRE_STATIC
#define TRE_DEF extern
#else
#define TRE_DEF static
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define TRE_MAX_NODES 64 // Max number of regex nodes in expression.
#define TRE_MAX_BUFLEN 128 // Max length of character-class buffer.
typedef struct tre_node tre_node;
typedef struct tre_comp tre_comp;
struct tre_node {
unsigned char type;
union {
char ch; // character
char *cc; // character class buffer
unsigned short mn[2]; // {m,n} quantifier
} u;
};
struct tre_comp {
tre_node nodes[TRE_MAX_NODES];
char buffer[TRE_MAX_BUFLEN];
};
// Compile regex string pattern as tre_comp struct tregex
TRE_DEF int tre_compile(const char *pattern, tre_comp *tregex);
// Match tregex in text and return the match start or null if there is no match
// If end is not null set it to the match end
TRE_DEF const char *tre_match(const tre_comp *tregex, const char *text, const char **end);
// Same but compiles pattern then matches
TRE_DEF const char *tre_compile_match(const char *pattern, const char *text, const char **end);
// Print the pattern
TRE_DEF void tre_print(const tre_comp *tregex);
#ifdef __cplusplus
}
#endif
#endif // TRE_H_INCLUDE
/*
------------------------------------------------------------------------------
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - MIT License
Copyright (c) 2018 kokke, monolifed
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
*/
有不符合C语言代码规范的地方吗