forked from JavaTX/JavaCompilerCore
Grammatik um recordPattern erweitert
This commit is contained in:
parent
0311f5ed77
commit
9a780127c0
@ -575,7 +575,7 @@ switchBlockStatementGroup
|
||||
;
|
||||
|
||||
switchLabel
|
||||
: CASE (constantExpression=expression | enumConstantName=IDENTIFIER | typeType varName=identifier) ':'
|
||||
: CASE (constantExpression=expression | enumConstantName=IDENTIFIER | pattern) ':'
|
||||
| DEFAULT ':'
|
||||
;
|
||||
|
||||
@ -652,7 +652,30 @@ expression
|
||||
|
||||
// Java17
|
||||
pattern
|
||||
: variableModifier* typeType? annotation* identifier
|
||||
: primaryPattern
|
||||
| guardedPattern
|
||||
;
|
||||
|
||||
primaryPattern
|
||||
: typePattern
|
||||
| recordPattern
|
||||
| '(' pattern ')'
|
||||
;
|
||||
|
||||
recordPattern
|
||||
: typeType recordStructurePattern identifier?
|
||||
;
|
||||
|
||||
typePattern
|
||||
: variableModifier* typeType? identifier
|
||||
;
|
||||
|
||||
recordStructurePattern
|
||||
: '(' recordComponentPatternList? ')'
|
||||
;
|
||||
|
||||
recordComponentPatternList
|
||||
: pattern (',' pattern)*
|
||||
;
|
||||
|
||||
// Java8
|
||||
@ -691,14 +714,13 @@ switchExpression
|
||||
|
||||
// Java17
|
||||
switchLabeledRule
|
||||
: CASE (expressionList | NULL_LITERAL | guardedPattern) (ARROW | COLON) switchRuleOutcome
|
||||
: CASE (expressionList | NULL_LITERAL | pattern) (ARROW | COLON) switchRuleOutcome
|
||||
| DEFAULT (ARROW | COLON) switchRuleOutcome
|
||||
;
|
||||
|
||||
// Java17
|
||||
guardedPattern
|
||||
: '(' guardedPattern ')'
|
||||
| variableModifier* typeType annotation* identifier ('&&' expression)*
|
||||
: variableModifier* typeType? annotation* identifier ('&&' expression)*
|
||||
| guardedPattern '&&' expression
|
||||
;
|
||||
|
||||
|
@ -13,8 +13,7 @@ import de.dhbwstuttgart.parser.JavaTXParser;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Dieser Test pr�ft nur, ob .java-Dateien fehlerfrei geparst werden. Der
|
||||
* dabei erstellte Syntaxbaum wird nicht kontrolliert.
|
||||
* Dieser Test pr�ft nur, ob .java-Dateien fehlerfrei geparst werden. Der dabei erstellte Syntaxbaum wird nicht kontrolliert.
|
||||
*
|
||||
* @author janulrich
|
||||
*
|
||||
@ -26,6 +25,7 @@ public class GeneralParserTest {
|
||||
public void run() {
|
||||
|
||||
List<String> filenames = new ArrayList<String>();
|
||||
|
||||
filenames.add("NewTest.jav");
|
||||
filenames.add("FieldInitializationTest.jav");
|
||||
filenames.add("ImportTest.jav");
|
||||
|
Loading…
Reference in New Issue
Block a user