Commit Graph

91 Commits (f15a5cae348e19b31f4e50358616629a075d4d79)

Author SHA1 Message Date
Aadhavan Srinivasan f15a5cae34 Store all states visited in a single run of 'addStateToList()' in a slice
Aadhavan Srinivasan 62ca1a872a Made zeroLengthMatchState() return a pointer; reduced the number of comparisons performd by nfaState.equals
Aadhavan Srinivasan 99230b49de Use new function signature for zeroLengthMatchState()
Aadhavan Srinivasan 22ead83625 Fixed assertion matching
Aadhavan Srinivasan 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
Aadhavan Srinivasan 052de55826 question() now returns 2 values
Aadhavan Srinivasan d2ad0d95a8 Modified question operator so that it doesn't create an unnecessary zero-state
Aadhavan Srinivasan ccf3b3b299 More progress on implementing PCRE matching
Aadhavan Srinivasan 1d4f695f8f Wrote function to check if a state is in an nfaState, based on the Equals function
Aadhavan Srinivasan 8534174ea1 Use pointers instead of values
Aadhavan Srinivasan ed4ffde64e REFACTOR NEEDED: Added another special case; insert instead of appending into currentStates
Aadhavan Srinivasan fbc9bea9fb Commented out unused functions; use new nfaState parameters
Aadhavan Srinivasan 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).
Aadhavan Srinivasan 858e535fba Continued implementing Thompson's algorithm
Aadhavan Srinivasan 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.
Aadhavan Srinivasan d4e8cb74fd Replaced pointer to nfaState with nfaState
Aadhavan Srinivasan 3ce611d121 More work towards implementing PCRE matching
Aadhavan Srinivasan e0253dfaf3 Change kleene() to an alternation-style construct
Aadhavan Srinivasan 753e973d82 Started rewrite of matching algorithm, got concatenation and alternation done, kleene and zero-state stuff is next
Aadhavan Srinivasan 5563a70568 Reverse the order in which I pop states for alternation, because this messes with the left branch-right branch thing
Aadhavan Srinivasan de0d7345a8 Store left and right branches of alternation separately
Aadhavan Srinivasan ad273b0c68 Trying to emulate backtracking by using string pointers within threads (something similar to rsc's 2nd regexp article)
Aadhavan Srinivasan e167cdb2cb Fixed mistake in test output
Aadhavan Srinivasan 1fd48ae614 Store the current string pointer as a 'thread variable' (allows us to simulate backtracking)
Aadhavan Srinivasan fbc9dfcc95 Trying something out; we'll see if it works
Aadhavan Srinivasan bc32e0cb76 Started working on converting to PCRE matching rules (prefer left branch of alternation)
Aadhavan Srinivasan ad0f7d0178 Added new state fields to tell if a state is a question or alternation
Aadhavan Srinivasan 4e597f8eb1 Implemented a priority-queue to use while matching
Aadhavan Srinivasan 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)
Aadhavan Srinivasan 7e6b02632f Added more tests; commented out tests that I am failing
Aadhavan Srinivasan f94e3f2e71 Added comments
Aadhavan Srinivasan b129d83c3f Added function to reset threads
Aadhavan Srinivasan 43aa7b5876 Updated documentation
Aadhavan Srinivasan 9a3bfca313 Renamed unique_append to uniqueAppend
Aadhavan Srinivasan b6ab54f6dd Reset threads when findAllSubmatchHelper is called
Aadhavan Srinivasan 6a96c98d04 Fixed bug where the regex '(()|.)(b)' wouldn't compile
Aadhavan Srinivasan a46d2f4546 Updated comments
Aadhavan Srinivasan c88ebd1aa5 Added comments explaining what a Match is
Aadhavan Srinivasan fd102292c6 Added example for FindSubmatch
Aadhavan Srinivasan 6d692d0dfc Rename Group.toString() to Group.String()
Aadhavan Srinivasan 7c4538a259 Added 'example' file that contains testable examples
Aadhavan Srinivasan 2a9ae0b68a Wrote test for 'FindSubmatch'
Aadhavan Srinivasan 783ae2ad10 Updated call to 'isValid' with call to 'IsValid'
Aadhavan Srinivasan b5e6bc112c Wrote 'reg.FindSubmatch()' which returns the leftmost match with submatches, renamed 'isValid' to 'IsValid' to export it, renamed 'ToString' to 'String'
Aadhavan Srinivasan 206fea34cd Added function to return the number of subexpressions in the group
Aadhavan Srinivasan fcdb23524a Added more documentation
Aadhavan Srinivasan ac936659b6 Updated documentation
Aadhavan Srinivasan e6dba9fdcf Updated documentation
Aadhavan Srinivasan 30779a446b Updated documentation
Aadhavan Srinivasan f629a0f08f Added 'mustCompile' which panicks if there is an error compiling