Groups | Search | Server Info | Login | Register
Groups > comp.arch.embedded > #32317
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: Static regex for embedded systems |
| Date | 2025-01-21 16:40 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <vmof51$5g9v$1@dont-email.me> (permalink) |
| References | <vmob4o$3ssqn$2@dont-email.me> |
On 21/01/2025 15:31, pozz wrote: > Many times I need to parse/decode a text string that comes from an > external system, over a serial bus, MQTT, and so on. > > Many times this string has a fixed syntax/layout. In order to parse this > string, I everytime create a custom parser that can be tedious, > cumbersom and error prone. > > For example, suppose you have to decode a string from a modem that uses > AT commands. Many answers from the modem has the following schema: > > \r\n+<prefix>: <field1>,<field2>\r\n > \r\nOK\r\n > > The prefix is known, the number and type of fileds are known too. With > regex, the parser would be simple. > There are plenty of libraries for run-time regular expressions - they have been in the C++ standard library since C++11 (IIRC). But run-time parsing of regex strings and matching for the input string will be very time and space costly in a small embedded system. You want compile-time regular expression handling. This had been planned for inclusion in C++23 (and therefore part of the current GNU ARM Embedded toolchain, if that's what you are using), but it didn't make it. However, there are standalone compile-time regex libraries for C++ using templates and compile-time functions, which will in effect generate specialised parsers from the regex strings.
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar
Static regex for embedded systems pozz <pozzugno@gmail.com> - 2025-01-21 15:31 +0100
Re: Static regex for embedded systems David Brown <david.brown@hesbynett.no> - 2025-01-21 16:40 +0100
Re: Static regex for embedded systems Stefan Reuther <stefan.news@arcor.de> - 2025-01-21 17:03 +0100
Re: Static regex for embedded systems pozz <pozzugno@gmail.com> - 2025-01-21 18:03 +0100
Re: Static regex for embedded systems Hans-Bernhard Bröker <HBBroeker@gmail.com> - 2025-01-21 20:40 +0100
Re: Static regex for embedded systems "Niocláiſín Cóilín de Ġloſtéir" <Master_Fontaine_is_dishonest@Strand_in_London.Gov.UK> - 2025-01-22 00:41 +0100
Re: Static regex for embedded systems George Neuner <gneuner2@comcast.net> - 2025-01-21 19:38 -0500
Re: Static regex for embedded systems David Brown <david.brown@hesbynett.no> - 2025-01-22 10:59 +0100
Re: Static regex for embedded systems George Neuner <gneuner2@comcast.net> - 2025-01-22 18:23 -0500
Re: Static regex for embedded systems Stefan Reuther <stefan.news@arcor.de> - 2025-01-22 17:53 +0100
Re: Static regex for embedded systems George Neuner <gneuner2@comcast.net> - 2025-01-22 18:33 -0500
csiph-web