62ca1a872a
Made zeroLengthMatchState() return a pointer; reduced the number of comparisons performd by nfaState.equals
2025-02-08 16:06:14 -05:00
99230b49de
Use new function signature for zeroLengthMatchState()
2025-02-08 16:05:35 -05:00
22ead83625
Fixed assertion matching
2025-02-07 16:19:36 -05:00
3604486a9b
Used Pike's algorithm (an extension to Thompson's algorithm) (see Russ Cox's 2nd article); I think I almost have a working PCRE-style engine
2025-02-07 16:06:45 -05:00
052de55826
question() now returns 2 values
2025-02-07 16:04:46 -05:00
d2ad0d95a8
Modified question operator so that it doesn't create an unnecessary zero-state
2025-02-07 16:04:26 -05:00
ccf3b3b299
More progress on implementing PCRE matching
2025-02-06 22:08:56 -05:00
1d4f695f8f
Wrote function to check if a state is in an nfaState, based on the Equals function
2025-02-06 22:06:51 -05:00
8534174ea1
Use pointers instead of values
2025-02-06 22:06:22 -05:00
ed4ffde64e
REFACTOR NEEDED: Added another special case; insert instead of appending into currentStates
2025-02-05 22:51:55 -05:00
fbc9bea9fb
Commented out unused functions; use new nfaState parameters
2025-02-05 22:23:31 -05:00
cca8c7cda2
Got rid of transitions parameter, changed how kleene state is processed
...
I replaced the transition parameter for nfaState, replacing it with a
single nfaState pointer. This is because any non-alternation state will
only have one next state, so the map was just added complexity.
I changed alternation processing - instead of having their own dedicated
fields, they just use the new 'next' parameter, and another one called
'splitState'.
I also changed the kleene state processing to remove the unecessary
empty state in the right-side alternation (it actually messed up my
matching).
2025-02-05 22:20:28 -05:00
858e535fba
Continued implementing Thompson's algorithm
2025-02-05 18:01:36 -05:00
7c62ba6bfd
Started implementing Thompson's algorithm for matching, because the old one was completely backtracking (so it would enter infinite loops on something like '(a*)*' )
...
The git diff claims that a ton of code was changed, but most of it was just indentation changes.
2025-02-05 12:21:12 -05:00
d4e8cb74fd
Replaced pointer to nfaState with nfaState
2025-02-05 11:32:20 -05:00
3ce611d121
More work towards implementing PCRE matching
2025-02-04 14:09:24 -05:00
e0253dfaf3
Change kleene() to an alternation-style construct
2025-02-04 14:09:04 -05:00
753e973d82
Started rewrite of matching algorithm, got concatenation and alternation done, kleene and zero-state stuff is next
2025-02-03 22:01:52 -05:00
5563a70568
Reverse the order in which I pop states for alternation, because this messes with the left branch-right branch thing
2025-02-03 21:59:41 -05:00
de0d7345a8
Store left and right branches of alternation separately
2025-02-03 21:59:05 -05:00
ad273b0c68
Trying to emulate backtracking by using string pointers within threads (something similar to rsc's 2nd regexp article)
2025-02-03 16:50:11 -05:00
e167cdb2cb
Fixed mistake in test output
2025-02-03 16:49:30 -05:00
1fd48ae614
Store the current string pointer as a 'thread variable' (allows us to simulate backtracking)
2025-02-03 16:49:10 -05:00
fbc9dfcc95
Trying something out; we'll see if it works
2025-02-03 16:47:53 -05:00
bc32e0cb76
Started working on converting to PCRE matching rules (prefer left branch of alternation)
2025-02-03 14:06:14 -05:00
ad0f7d0178
Added new state fields to tell if a state is a question or alternation
2025-02-03 14:05:53 -05:00
4e597f8eb1
Implemented a priority-queue to use while matching
2025-02-03 14:05:30 -05:00
ef476e8875
Reverse the order of the numeric range before adding it, to maintain compatibility with PCRE matching rules (even though I don't implement them, if I do in the future)
2025-02-02 13:46:48 -05:00
7e6b02632f
Added more tests; commented out tests that I am failing
2025-02-02 13:46:08 -05:00
f94e3f2e71
Added comments
2025-02-02 12:44:06 -05:00
b129d83c3f
Added function to reset threads
2025-02-02 12:43:40 -05:00
43aa7b5876
Updated documentation
2025-02-02 12:42:38 -05:00
9a3bfca313
Renamed unique_append to uniqueAppend
2025-02-02 12:42:29 -05:00
b6ab54f6dd
Reset threads when findAllSubmatchHelper is called
2025-02-02 12:42:00 -05:00
6a96c98d04
Fixed bug where the regex '(()|.)(b)' wouldn't compile
2025-02-01 19:20:33 -05:00
a46d2f4546
Updated comments
2025-02-01 18:07:31 -05:00
c88ebd1aa5
Added comments explaining what a Match is
2025-02-01 18:05:55 -05:00
fd102292c6
Added example for FindSubmatch
2025-02-01 18:05:43 -05:00
6d692d0dfc
Rename Group.toString() to Group.String()
2025-02-01 12:51:32 -05:00
7c4538a259
Added 'example' file that contains testable examples
2025-02-01 12:50:49 -05:00
2a9ae0b68a
Wrote test for 'FindSubmatch'
2025-02-01 11:09:05 -05:00
783ae2ad10
Updated call to 'isValid' with call to 'IsValid'
2025-02-01 11:06:26 -05:00
b5e6bc112c
Wrote 'reg.FindSubmatch()' which returns the leftmost match with submatches, renamed 'isValid' to 'IsValid' to export it, renamed 'ToString' to 'String'
2025-02-01 11:06:03 -05:00
206fea34cd
Added function to return the number of subexpressions in the group
2025-02-01 11:04:49 -05:00
fcdb23524a
Added more documentation
2025-02-01 11:04:24 -05:00
ac936659b6
Updated documentation
2025-01-31 16:52:26 -05:00
e6dba9fdcf
Updated documentation
2025-01-31 16:51:46 -05:00
30779a446b
Updated documentation
2025-01-31 16:46:19 -05:00
f629a0f08f
Added 'mustCompile' which panicks if there is an error compiling
2025-01-31 16:46:05 -05:00
6869cd00a2
Return error instead of nil when 'Find' fails
2025-01-31 10:52:38 -05:00