mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RegExp: fix python regex conditional reference parsing
This commit is contained in:
@@ -391,7 +391,18 @@ public class RegExpParser implements PsiParser {
|
||||
builder.error("Group name or number expected");
|
||||
}
|
||||
checkMatches(builder, RegExpTT.GROUP_END, "Unclosed group reference");
|
||||
parseGroupEnd(builder);
|
||||
if (!parseBranch(builder)) {
|
||||
patternExpected(builder);
|
||||
}
|
||||
else {
|
||||
if (builder.getTokenType() == RegExpTT.UNION) {
|
||||
builder.advanceLexer();
|
||||
if (!parseBranch(builder)) {
|
||||
patternExpected(builder);
|
||||
}
|
||||
}
|
||||
checkMatches(builder, RegExpTT.GROUP_END, "Unclosed group");
|
||||
}
|
||||
marker.done(RegExpElementTypes.PY_COND_REF);
|
||||
}
|
||||
else if (type == RegExpTT.PROPERTY) {
|
||||
|
||||
@@ -193,6 +193,7 @@ public class RegExpParsingTest extends ParsingTestCase {
|
||||
public void testGroups40() throws IOException { doCodeTest("(?(name)yes-pattern|{"); }
|
||||
public void testGroups41() throws IOException { doCodeTest("(?>atomic)"); }
|
||||
public void testGroups42() throws IOException { doCodeTest("(?:non-capturing)"); }
|
||||
public void testGroups43() throws IOException { doCodeTest("(?(name)yes-pattern|no_pattern|maybe-pattern)"); }
|
||||
|
||||
public void testEscapes1() throws IOException { doCodeTest("\\q"); }
|
||||
public void testEscapes2() throws IOException { doCodeTest("\\#"); }
|
||||
|
||||
@@ -5,50 +5,49 @@ REGEXP_FILE
|
||||
PsiElement(PYTHON_COND_REF)('(?(')
|
||||
PsiElement(NAME)('name')
|
||||
PsiElement(GROUP_END)(')')
|
||||
RegExpPatternImpl: <yes-pattern|no-pattern>
|
||||
RegExpBranchImpl: <yes-pattern>
|
||||
RegExpCharImpl: <y>
|
||||
PsiElement(CHARACTER)('y')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <s>
|
||||
PsiElement(CHARACTER)('s')
|
||||
RegExpCharImpl: <->
|
||||
PsiElement(CHARACTER)('-')
|
||||
RegExpCharImpl: <p>
|
||||
PsiElement(CHARACTER)('p')
|
||||
RegExpCharImpl: <a>
|
||||
PsiElement(CHARACTER)('a')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <r>
|
||||
PsiElement(CHARACTER)('r')
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
PsiElement(UNION)('|')
|
||||
RegExpBranchImpl: <no-pattern>
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
RegExpCharImpl: <o>
|
||||
PsiElement(CHARACTER)('o')
|
||||
RegExpCharImpl: <->
|
||||
PsiElement(CHARACTER)('-')
|
||||
RegExpCharImpl: <p>
|
||||
PsiElement(CHARACTER)('p')
|
||||
RegExpCharImpl: <a>
|
||||
PsiElement(CHARACTER)('a')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <r>
|
||||
PsiElement(CHARACTER)('r')
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
RegExpBranchImpl: <yes-pattern>
|
||||
RegExpCharImpl: <y>
|
||||
PsiElement(CHARACTER)('y')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <s>
|
||||
PsiElement(CHARACTER)('s')
|
||||
RegExpCharImpl: <->
|
||||
PsiElement(CHARACTER)('-')
|
||||
RegExpCharImpl: <p>
|
||||
PsiElement(CHARACTER)('p')
|
||||
RegExpCharImpl: <a>
|
||||
PsiElement(CHARACTER)('a')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <r>
|
||||
PsiElement(CHARACTER)('r')
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
PsiElement(UNION)('|')
|
||||
RegExpBranchImpl: <no-pattern>
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
RegExpCharImpl: <o>
|
||||
PsiElement(CHARACTER)('o')
|
||||
RegExpCharImpl: <->
|
||||
PsiElement(CHARACTER)('-')
|
||||
RegExpCharImpl: <p>
|
||||
PsiElement(CHARACTER)('p')
|
||||
RegExpCharImpl: <a>
|
||||
PsiElement(CHARACTER)('a')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <r>
|
||||
PsiElement(CHARACTER)('r')
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
PsiElement(GROUP_END)(')')
|
||||
@@ -6,33 +6,32 @@ REGEXP_FILE
|
||||
PsiElement(PYTHON_COND_REF)('(?(')
|
||||
PsiElement(NAME)('name')
|
||||
PsiElement(GROUP_END)(')')
|
||||
RegExpPatternImpl: <yes-pattern|>
|
||||
RegExpBranchImpl: <yes-pattern>
|
||||
RegExpCharImpl: <y>
|
||||
PsiElement(CHARACTER)('y')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <s>
|
||||
PsiElement(CHARACTER)('s')
|
||||
RegExpCharImpl: <->
|
||||
PsiElement(CHARACTER)('-')
|
||||
RegExpCharImpl: <p>
|
||||
PsiElement(CHARACTER)('p')
|
||||
RegExpCharImpl: <a>
|
||||
PsiElement(CHARACTER)('a')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <r>
|
||||
PsiElement(CHARACTER)('r')
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
PsiElement(UNION)('|')
|
||||
PsiErrorElement:Dangling metacharacter
|
||||
<empty list>
|
||||
RegExpBranchImpl: <yes-pattern>
|
||||
RegExpCharImpl: <y>
|
||||
PsiElement(CHARACTER)('y')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <s>
|
||||
PsiElement(CHARACTER)('s')
|
||||
RegExpCharImpl: <->
|
||||
PsiElement(CHARACTER)('-')
|
||||
RegExpCharImpl: <p>
|
||||
PsiElement(CHARACTER)('p')
|
||||
RegExpCharImpl: <a>
|
||||
PsiElement(CHARACTER)('a')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <r>
|
||||
PsiElement(CHARACTER)('r')
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
PsiElement(UNION)('|')
|
||||
PsiErrorElement:Dangling metacharacter
|
||||
<empty list>
|
||||
RegExpQuantifierImpl: <{>
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiErrorElement:Number expected
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
REGEXP_FILE
|
||||
RegExpPatternImpl: <(?(name)yes-pattern|no_pattern|maybe-pattern>
|
||||
RegExpBranchImpl: <(?(name)yes-pattern|no_pattern>
|
||||
RegExpPyCondRefImpl: <(?(name)yes-pattern|no_pattern>
|
||||
PsiElement(PYTHON_COND_REF)('(?(')
|
||||
PsiElement(NAME)('name')
|
||||
PsiElement(GROUP_END)(')')
|
||||
RegExpBranchImpl: <yes-pattern>
|
||||
RegExpCharImpl: <y>
|
||||
PsiElement(CHARACTER)('y')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <s>
|
||||
PsiElement(CHARACTER)('s')
|
||||
RegExpCharImpl: <->
|
||||
PsiElement(CHARACTER)('-')
|
||||
RegExpCharImpl: <p>
|
||||
PsiElement(CHARACTER)('p')
|
||||
RegExpCharImpl: <a>
|
||||
PsiElement(CHARACTER)('a')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <r>
|
||||
PsiElement(CHARACTER)('r')
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
PsiElement(UNION)('|')
|
||||
RegExpBranchImpl: <no_pattern>
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
RegExpCharImpl: <o>
|
||||
PsiElement(CHARACTER)('o')
|
||||
RegExpCharImpl: <_>
|
||||
PsiElement(CHARACTER)('_')
|
||||
RegExpCharImpl: <p>
|
||||
PsiElement(CHARACTER)('p')
|
||||
RegExpCharImpl: <a>
|
||||
PsiElement(CHARACTER)('a')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <r>
|
||||
PsiElement(CHARACTER)('r')
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
PsiErrorElement:Unclosed group
|
||||
<empty list>
|
||||
PsiElement(UNION)('|')
|
||||
RegExpBranchImpl: <maybe-pattern>
|
||||
RegExpCharImpl: <m>
|
||||
PsiElement(CHARACTER)('m')
|
||||
RegExpCharImpl: <a>
|
||||
PsiElement(CHARACTER)('a')
|
||||
RegExpCharImpl: <y>
|
||||
PsiElement(CHARACTER)('y')
|
||||
RegExpCharImpl: <b>
|
||||
PsiElement(CHARACTER)('b')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <->
|
||||
PsiElement(CHARACTER)('-')
|
||||
RegExpCharImpl: <p>
|
||||
PsiElement(CHARACTER)('p')
|
||||
RegExpCharImpl: <a>
|
||||
PsiElement(CHARACTER)('a')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <t>
|
||||
PsiElement(CHARACTER)('t')
|
||||
RegExpCharImpl: <e>
|
||||
PsiElement(CHARACTER)('e')
|
||||
RegExpCharImpl: <r>
|
||||
PsiElement(CHARACTER)('r')
|
||||
RegExpCharImpl: <n>
|
||||
PsiElement(CHARACTER)('n')
|
||||
PsiErrorElement:Unmatched closing ')'
|
||||
<empty list>
|
||||
PsiElement(GROUP_END)(')')
|
||||
Reference in New Issue
Block a user