Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding + and ? #2

Open
vsraptor opened this issue Oct 3, 2020 · 0 comments
Open

Adding + and ? #2

vsraptor opened this issue Oct 3, 2020 · 0 comments

Comments

@vsraptor
Copy link

vsraptor commented Oct 3, 2020

After you add the parser stuff, you can add support for + and ?, with something like this :


def zero_one(state): #?
	start = new_state(False)
	end = new_state(True)

	add_epsilon(start, end)
	add_epsilon(start, state.start)
	add_epsilon(state.end, end)
	state.end.is_end = False

	return AttrDict({ 'start': start, 'end': end })

def oneORmore(nfa): #+
	once = AttrDict(nfa) #copy or deepcopy
	once.end.is_end = False
	return concat(once, closure(nfa))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant