diff --git a/java/src/processing/mode/java/pdex/SourceUtils.java b/java/src/processing/mode/java/pdex/SourceUtils.java index 66703b246..8a1a20693 100644 --- a/java/src/processing/mode/java/pdex/SourceUtils.java +++ b/java/src/processing/mode/java/pdex/SourceUtils.java @@ -55,8 +55,12 @@ public class SourceUtils { + // Positive lookahead and lookbehind are needed to match all type constructors + // in code like `int(byte(245))` where first bracket matches as last + // group in "^int(" but also as a first group in "(byte(". Lookahead and + // lookbehind won't consume the shared character. public static final Pattern TYPE_CONSTRUCTOR_REGEX = - Pattern.compile("(?:^|\\W)(int|char|float|boolean|byte)(?:\\s*\\()", + Pattern.compile("(?<=^|\\W)(int|char|float|boolean|byte)(?=\\s*\\()", Pattern.MULTILINE); public static List replaceTypeConstructors(CharSequence source) {