summaryrefslogtreecommitdiff
path: root/src (unfollow)
Commit message (Collapse)AuthorFilesLines
2025-07-15Use `shouldConcat()` in decision of `escapingStateSte()`EuAndreh2-11/+15
* src/paca.mjs (escapingStateStep): Use `shouldConcat()` instead of only checking if we're on the last char. We abuse it a bit by passing `null` as the first argument, since it is being escaped. (nonConcatOperators, shouldConcat): Hoist the definition of both above `escapingStateStep()`, so that they're defined before being used. * tests/paca.mjs (test_shouldConcat): Add test case where `null` is explicitly passed as the first argument.
2025-07-15Support tokenizing character class expressions [a-z]EuAndreh2-5/+349
* src/paca.mjs (classStateStep): New function equivalent to `rangeStateStep()` for character class expressions. For now it knowns how to handle escaping ([abc\-_]), simple ranges ([a-z]), negation ([^abc]) and the hyphen literal as the first char ([-a-z_]). * tests.paca.mjs (test_classStateStep): New test entry has a test case each scenario described above.
2025-07-13tests/paca.mjs (test_rangeStateStep): Finish test cases for rangeStateStepEuAndreh1-0/+139
2025-07-13src/paca.mjs (rangeStateStep): Fix typo in SyntaxError messageEuAndreh1-1/+1
2025-07-13src/paca.mjs (rangeStateStep): Refine indentation and alignmentEuAndreh1-3/+3
2025-07-13src/paca.mjs ({escaping,range}StateStep): Add leading underscore to ignored argsEuAndreh1-2/+2
2025-07-13src/paca.mjs (rangeStateStep): Return ValueError when range number decreasesEuAndreh1-1/+2
2025-07-13Add first test for `rangeStateStep()`EuAndreh1-0/+17
* tests/paca.mjs (test_rangeStateStep): Add first test case, for when we find a closing "}" when no comma was seen.
2025-07-13Hoist `numFromDigits()` before its usageEuAndreh2-22/+22
* src/paca.mjs (numFromDigits): Move it to before the *StateStep functions, as it is now used in `rangeStateStep()` function. So instead of letting it be defined afters its usage, move it up. * tests/paca.mjs: Do the same hoisting to the import of the `numFromDigits` name, to the definition of `test_numFromDigits` and its inclusion in the order of the call to `runTests()`.
2025-07-13Add "[" to the possible characters of TRANSITION_FNS.EuAndreh2-0/+30
Introducing "[" now we will start to write the code to parse the character class expressions, i.e. [a-z0-9]. The `context` key will contain a `set` with all the literal characters that were found, and all the ranges too. For parsing the ranges, a `range` key equivalent to the one for the {m,n} range is used. Despite the superficial syntax being simmilar, its logic, semantic and implementation will be different. * src/paca.mjs (TRANSITION_FNS) <"[">: Add new transition function for handling the start of a character class expression. * tests/paca.mjs (TRANSITION_FNS): Add a singular test entry, that exercises the conditionless body of the function.
2025-07-13Add simple test for TRANSITION_FNSEuAndreh2-2/+35
* src/paca.mjs (TRANSITION_FNS): Add trailing underscore to ignored arguments, even though it breaks the name of the `_state` and `context` destructuring arguments. * tests/paca.mjs (test_TRANSITION_FNS): Add new test function with a single case for each transition character. Since these transitions are unconditional and contain no logic, this single sample test is enough to cover for all of its behaviour.
2025-07-12Revert "src/paca.mjs: Temporarily export internal functions"EuAndreh1-4/+4
This reverts commit 15f206e4940cb80ff98eea7c376d9c618f80ed0e.
2025-07-12src/paca.mjs: Temporarily export internal functionsEuAndreh1-4/+4
2025-07-11src/paca.mjs (tokenizeRegexStep): Simplify bodyEuAndreh1-105/+127
When handling a custom state, dispatch it to the appropriate function in `STATE_FNS`; and when looking for chars that enters these custom states, dispatch it to the appropriate function in `TRANSITION_FNS`. The body of each part didn't change, so no tests had to be modified. But now we can write specific tests for each case, and remove the bulk of the logic out of `tokenizeRegexFn()`.
2025-07-11tests/paca.mjs (test_tokenizeRegexStep): Simplify table valuesEuAndreh1-704/+322
2025-07-11src/paca.mjs (tokenizeRegexStep): Fix missing concat when escapingEuAndreh1-5/+8
2025-07-11tests/paca.mjs: Add tests for numFromDigits()EuAndreh1-0/+17
2025-07-11src/paca.mjs: Remove calls to arr.concat([]) with unneeded wrapping ↵EuAndreh1-14/+6
singleton array
2025-07-11src/paca.mjs (tokenizeRegexStep): Support tokenizing range exps {m,n}EuAndreh2-2/+638
2025-07-11src/paca.mjs (tokenizeRegexStep): Include `context` key in reduced stateEuAndreh2-121/+152
2025-07-11src/paca.mjs: Move error detection from tokenizeRegexStep => tokenizeRegexEuAndreh2-26/+34
2025-07-11tests/paca.mjs (test_tokenizeRegexStep): Compute `char` and `index`EuAndreh1-20/+7
2025-07-11src/paca.mjs: Remove unused repeat(3) importEuAndreh1-1/+1
2025-07-09Makefile: Minor fixes of indentation and alignmentEuAndreh1-3/+3
2025-07-09Finish implementation of unit testsEuAndreh2-31/+881
2025-07-07Implement v0 version of NFA and DFA; WIP testsEuAndreh6-0/+1898