mirror of
https://github.com/corda/corda.git
synced 2025-01-24 21:37:05 +00:00
62d1964779
A program for the PikeVM corresponds to a regular expression pattern. The program matches the character sequence in left-to-right order. However, for look-behind expressions, we will want to match the character sequence backwards. To this end, it is nice that regular expression patterns can be reversed in a straight-forward manner. However, it would be nice if we could avoid multiple parsing passes and simply parse even look-behind expressions as if they were look-ahead ones, and then simply reverse the program for that part. Happily, it is not difficult to reverse the program so it is equivalent to matching the pattern backwards. There is one catch, though. Imagine matching the sequence "a" against the regular expression "(a?)a?". If we match forward, the group will match the letter "a", when matching backwards, it will match the empty string. So, while the reverse pattern is equivalent to the forward pattern in terms of "does the pattern match that sequence", but not its sub-matches. For that reason, Java simply ignores capturing groups in look-behind patterns (and for consistency, the same holds for look-ahead patterns). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
38 lines
910 B
Java
38 lines
910 B
Java
/* Copyright (c) 2008-2013, Avian Contributors
|
|
|
|
Permission to use, copy, modify, and/or distribute this software
|
|
for any purpose with or without fee is hereby granted, provided
|
|
that the above copyright notice and this permission notice appear
|
|
in all copies.
|
|
|
|
There is NO WARRANTY for this software. See license.txt for
|
|
details. */
|
|
|
|
package regex;
|
|
|
|
/**
|
|
* Opcodes for the Pike VM.
|
|
* <p>
|
|
* See {@link PikeVM}.
|
|
* </p>
|
|
*
|
|
* @author Johannes Schindelin
|
|
*/
|
|
interface PikeVMOpcodes {
|
|
final static int DOT = -1;
|
|
final static int DOTALL = -2;
|
|
|
|
final static int CHARACTER_CLASS = -20;
|
|
|
|
final static int LOOKAHEAD = -30;
|
|
|
|
final static int SAVE_OFFSET = -40;
|
|
|
|
final static int SPLIT = -50;
|
|
final static int SPLIT_JMP = -51; // this split prefers to jump
|
|
final static int JMP = -52;
|
|
|
|
final static int SINGLE_ARG_START = CHARACTER_CLASS;
|
|
final static int SINGLE_ARG_END = JMP;
|
|
}
|