Class JPPAnnotationParser
java.lang.Object
org.variantsync.diffdetective.feature.PreprocessorAnnotationParser
org.variantsync.diffdetective.feature.jpp.JPPAnnotationParser
- All Implemented Interfaces:
AnnotationParser
Parses a JavaPP (Java PreProcessor) statement.
For example, given the annotation
//#if defined(A) || B(),
the class would parse new Or(new Literal("defined(A)"), new Literal("B()")).
The parser detects if, elif, else and endif annotations.
The given JPP statement might also be a line in a diff (i.e., preceded by a - or +).- Author:
- Alexander Schultheiß
-
Field Summary
FieldsFields inherited from class org.variantsync.diffdetective.feature.PreprocessorAnnotationParser
annotationPattern -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.prop4j.NodeparseFormula(String directive, String formula) Parses the feature formula of a preprocessor annotation line.Methods inherited from class org.variantsync.diffdetective.feature.PreprocessorAnnotationParser
parseAnnotation, parseAnnotationType
-
Field Details
-
JPP_ANNOTATION_REGEX
- See Also:
-
JPP_ANNOTATION_PATTERN
-
-
Constructor Details
-
JPPAnnotationParser
public JPPAnnotationParser()
-
-
Method Details
-
parseFormula
public org.prop4j.Node parseFormula(String directive, String formula) throws UnparseableFormulaException Description copied from class:PreprocessorAnnotationParserParses the feature formula of a preprocessor annotation line. It should abstract complex formulas (e.g., if they contain arithmetics or macro calls) as desired. For example, for the line"#if A && B == C", this method is should be called likeparseFormula("if", "A && B == C")(the exact arguments are determined byPreprocessorAnnotationParser.annotationPatternand it should return something likeand(var("A"), var("B==C")).This method is only called if
directiveactually requires a formula as determined byPreprocessorAnnotationParser.parseAnnotationType(java.lang.String).- Specified by:
parseFormulain classPreprocessorAnnotationParser- Parameters:
directive- as matched by the named capture groupdirectiveofPreprocessorAnnotationParser.annotationPatternformula- as matched by the named capture groupformulaofPreprocessorAnnotationParser.annotationPattern- Returns:
- the feature mapping
- Throws:
UnparseableFormulaException- ifformulais ill-formed.
-