mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-29 19:00:06 +00:00
Fix multiline RegEx iteration
In `.Multiline` mode: - `^` is now defined to assert the start of the string or that a "\n" or "\r" rune was parsed on last VM dispatch. - `$` is now defined to consume a newline sequence of "\n", "\r", or "\r\n" or to assert the end of the string.
This commit is contained in:
@@ -195,8 +195,12 @@ generate_code :: proc(c: ^Compiler, node: Node) -> (code: Program) {
|
||||
|
||||
case ^Node_Anchor:
|
||||
if .Multiline in c.flags {
|
||||
append(&code, Opcode.Multiline_Open)
|
||||
append(&code, Opcode.Multiline_Close)
|
||||
if specific.start {
|
||||
append(&code, Opcode.Assert_Start_Multiline)
|
||||
} else {
|
||||
append(&code, Opcode.Multiline_Open)
|
||||
append(&code, Opcode.Multiline_Close)
|
||||
}
|
||||
} else {
|
||||
if specific.start {
|
||||
append(&code, Opcode.Assert_Start)
|
||||
@@ -439,7 +443,7 @@ compile :: proc(tree: Node, flags: common.Flags) -> (code: Program, class_data:
|
||||
case .Save:
|
||||
continue
|
||||
|
||||
case .Assert_Start:
|
||||
case .Assert_Start, .Assert_Start_Multiline:
|
||||
break optimize_opening
|
||||
|
||||
case:
|
||||
|
||||
Reference in New Issue
Block a user