From f3911888915f6aa96e6b28bd2a98a662faf20f47 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Fri, 23 Sep 2022 14:55:58 +0100 Subject: Adds try, maybe and join operators with !, ? and ; respectively --- main/regexast.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'main/regexast.go') diff --git a/main/regexast.go b/main/regexast.go index 0aab053..a5a60c4 100644 --- a/main/regexast.go +++ b/main/regexast.go @@ -70,3 +70,23 @@ func (ast RegexASTMinimise) compileWith(next RegexState) RegexState { state.second = ast.content.compileWith(state) return state } + +type RegexASTTry struct { + content RegexAST +} +func (ast RegexASTTry) compileWith(next RegexState) RegexState { + return RegexGroupState{ + ast.content.compileWith(next), + next, + } +} + +type RegexASTMaybe struct { + content RegexAST +} +func (ast RegexASTMaybe) compileWith(next RegexState) RegexState { + return RegexGroupState { + next, + ast.content.compileWith(next), + } +} -- cgit v1.2.3