summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-07-16 10:32:04 -0300
committerEuAndreh <eu@euandre.org>2025-07-16 10:32:04 -0300
commit69e36152600599126d95ae1085b0777a830bc97b (patch)
tree43527bb37c38cde9921f579153e85edf915ce97f /Makefile
parentDifferentiate an "operator" from a "meta" character (diff)
downloadpaca-69e36152600599126d95ae1085b0777a830bc97b.tar.gz
paca-69e36152600599126d95ae1085b0777a830bc97b.tar.xz
Build NFA nodes for "." and "class" metacharacters
* src/paca.mjs (characterClass): Add function that builds the NFA node for `{ meta: "class" }`. This node leaves the "direct" and "transitions" keys empty, and add its data under the "meta" key. One option was to use an inline function that could simply be called directly during the search to check for a match, but instead I chose a data representation instead, in order to keep the NFA literal as obvious and self-representing as possible. Later, the searching part will have to properly interpret the data of "meta" properly, instead of blindly executing an opaque function. This does separate the compilation from execution logic, but keep the NFA clean of opaque closures. (wildcard): Add function that buildl the NFA node for `{ meta: "." }`. Similar to `characterClass()`, the new "meta" key contains pure data that represents the execution of the metacharacter during search. (baseNFA, literal): Rename the existing `baseNFA()` to `literal()`. Then add a new `baseNFA()` function that decides between a character literal and a metacharacter. (buildNFAStep): Instead of checking the type of `token`, we check if `token` has the "operator" attribute, since we now have metacharacters that also aren't strings. (classStateStep): Add missing "caret" key to the final metacharacter output. It was already being detected, just not included in the result. (escapingStateStep): Stick to 80 columns. * tests/paca.mjs (test_characterClass, test_wildcard, test_baseNFA): Add obligatory test cases. (test_buildNFAStep): Include test case for metacharacter.
Diffstat (limited to 'Makefile')
0 files changed, 0 insertions, 0 deletions