Comments (2)
The problem is that the parser is supposed to be a constexpr object. This is the whole idea behind the library.
Now there are some problems:
- I need to calculate the size of a finite automaton table to construct a lexer, so...
- I need all of the sizes of regexes in compile time
- I would like to allow inline terms but only if they are expressed as literals, like say "[0-9]"_r
For the char_term and 'string_term' it is easy, for the regex term I found a way but in c++20 standard:
template<std::size_t N>
struct regex
{
constexpr regex(const char (&str)[N])
{
std::ranges::copy(str, array);
}
char array[N];
};
template<regex a>
constexpr auto operator ""_r()
{
return a;
}
int main()
{
constexpr auto expr = "[0-9]"_r;
return 0;
}
Of course I could allow inlining them like this: regex_term("[0-9]"), but this seemed to verbose and the grammar looked ugly.
from ctpg.
the target of inline is to solve the priority of matching lexer along with the process of syntax parsed. And i don't know whether or not it can realized and how to realize it. whereas the style of writing is not very important.
from ctpg.
Related Issues (20)
- Can you explain how to use the lexer stand-alone? HOT 5
- Make tests and examples executables conditional HOT 6
- Constexpr parsing: non-constexpr containers HOT 5
- Parsing exponent notation in json-parser HOT 3
- Ignore all whitespaces but newlines HOT 3
- string_view buffer HOT 2
- [question] Cant Parameterize and "Seperate out" Parser HOT 7
- [question] Trouble Making Argument Lists HOT 1
- [Question] Is it applicable to parsing markdown? HOT 2
- [Question] Did I exceed the maximum number of rules? HOT 1
- Precedence When Matching/Lexing HOT 5
- [Feture Request] Integration with CTRE HOT 3
- how long to next release ? HOT 8
- Big Parsers? HOT 1
- Constexpr parsing of an array of ints HOT 6
- [Question] how to make the lexer NOT match a particular string HOT 2
- [question solved] constexpr variable 'p' must be initialized by a constant expression HOT 1
- Simple expression example and AST HOT 3
- [MSVC] Compilation error, unable to resolve operator overload of `ctpg::stdex::cbitset<N>::operator==` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ctpg.