Browse Source

Fix misnamed methods in the C# grammar.

Timur Sağlam 4 years ago
parent
commit
d72e17750e

+ 12 - 12
jplag.frontend.csharp-6/src/main/antlr4/de/jplag/csharp/grammar/CSharpLexer.g4

@@ -140,19 +140,19 @@ REAL_LITERAL:        ([0-9] ('_'* [0-9])*)? '.' [0-9] ('_'* [0-9])* ExponentPart
 CHARACTER_LITERAL:                   '\'' (~['\\\r\n\u0085\u2028\u2029] | CommonCharacter) '\'';
 REGULAR_STRING:                      '"'  (~["\\\r\n\u0085\u2028\u2029] | CommonCharacter)* '"';
 VERBATIUM_STRING:                    '@"' (~'"' | '""')* '"';
-INTERPOLATED_REGULAR_STRING_START:   '$"' { this.OnInterpolatedRegularStringStart(); } -> pushMode(INTERPOLATION_STRING);
-INTERPOLATED_VERBATIUM_STRING_START: '$@"'  { this.OnInterpolatedVerbatiumStringStart(); }  -> pushMode(INTERPOLATION_STRING);
+INTERPOLATED_REGULAR_STRING_START:   '$"' { this.onInterpolatedRegularStringStart(); } -> pushMode(INTERPOLATION_STRING);
+INTERPOLATED_VERBATIUM_STRING_START: '$@"'  { this.onInterpolatedVerbatiumStringStart(); }  -> pushMode(INTERPOLATION_STRING);
 
 //B.1.9 Operators And Punctuators
-OPEN_BRACE:               '{' { this.OnOpenBrace(); };
-CLOSE_BRACE:              '}' { this.OnCloseBrace(); };
+OPEN_BRACE:               '{' { this.onOpenBrace(); };
+CLOSE_BRACE:              '}' { this.onCloseBrace(); };
 OPEN_BRACKET:             '[';
 CLOSE_BRACKET:            ']';
 OPEN_PARENS:              '(';
 CLOSE_PARENS:             ')';
 DOT:                      '.';
 COMMA:                    ',';
-COLON:                    ':' { this.OnColon(); };
+COLON:                    ':' { this.onColon(); };
 SEMICOLON:                ';';
 PLUS:                     '+';
 MINUS:                    '-';
@@ -196,17 +196,17 @@ OP_RANGE:                 '..';
 mode INTERPOLATION_STRING;
 
 DOUBLE_CURLY_INSIDE:           '{{';
-OPEN_BRACE_INSIDE:             '{' { this.OpenBraceInside(); } -> skip, pushMode(DEFAULT_MODE);
-REGULAR_CHAR_INSIDE:           { this.IsRegularCharInside() }? SimpleEscapeSequence;
-VERBATIUM_DOUBLE_QUOTE_INSIDE: { this.IsVerbatiumDoubleQuoteInside() }? '""';
-DOUBLE_QUOTE_INSIDE:           '"' { this.OnDoubleQuoteInside(); } -> popMode;
-REGULAR_STRING_INSIDE:         { this.IsRegularCharInside() }? ~('{' | '\\' | '"')+;
-VERBATIUM_INSIDE_STRING:       { this.IsVerbatiumDoubleQuoteInside() }? ~('{' | '"')+;
+OPEN_BRACE_INSIDE:             '{' { this.openBraceInside(); } -> skip, pushMode(DEFAULT_MODE);
+REGULAR_CHAR_INSIDE:           { this.isRegularCharInside() }? SimpleEscapeSequence;
+VERBATIUM_DOUBLE_QUOTE_INSIDE: { this.isVerbatiumDoubleQuoteInside() }? '""';
+DOUBLE_QUOTE_INSIDE:           '"' { this.onDoubleQuoteInside(); } -> popMode;
+REGULAR_STRING_INSIDE:         { this.isRegularCharInside() }? ~('{' | '\\' | '"')+;
+VERBATIUM_INSIDE_STRING:       { this.isVerbatiumDoubleQuoteInside() }? ~('{' | '"')+;
 
 mode INTERPOLATION_FORMAT;
 
 DOUBLE_CURLY_CLOSE_INSIDE:      '}}' -> type(FORMAT_STRING);
-CLOSE_BRACE_INSIDE:             '}' { this.OnCloseBraceInside(); }   -> skip, popMode;
+CLOSE_BRACE_INSIDE:             '}' { this.onCloseBraceInside(); }   -> skip, popMode;
 FORMAT_STRING:                  ~'}'+;
 
 mode DIRECTIVE_MODE;

+ 1 - 1
jplag.frontend.csharp-6/src/main/antlr4/de/jplag/csharp/grammar/CSharpParser.g4

@@ -473,7 +473,7 @@ block
 	;
 
 local_variable_declaration
-	: (USING | REF | REF READONLY)? local_variable_type local_variable_declarator ( ','  local_variable_declarator { this.IsLocalVariableDeclaration() }? )*
+	: (USING | REF | REF READONLY)? local_variable_type local_variable_declarator ( ','  local_variable_declarator { this.isLocalVariableDeclaration() }? )*
 	| FIXED pointer_type fixed_pointer_declarators
 	;
 

+ 22 - 22
jplag.frontend.csharp-6/src/main/antlr4/de/jplag/csharp/grammar/CSharpPreprocessorParser.g4

@@ -7,19 +7,19 @@ parser grammar CSharpPreprocessorParser;
 options { tokenVocab=CSharpLexer; superClass=CSharpPreprocessorParserBase; }
 
 preprocessor_directive returns [Boolean value]
-	: DEFINE CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveDefine(); }  #preprocessorDeclaration
-	| UNDEF CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveUndef(); } #preprocessorDeclaration
-	| IF expr=preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveIf(); }	  #preprocessorConditional
-	| ELIF expr=preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveElif(); } #preprocessorConditional
-	| ELSE directive_new_line_or_sharp { this.OnPreprocessorDirectiveElse(); }    #preprocessorConditional
-	| ENDIF directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndif(); } #preprocessorConditional
-	| LINE (DIGITS STRING? | DEFAULT | DIRECTIVE_HIDDEN) directive_new_line_or_sharp { this.OnPreprocessorDirectiveLine(); } #preprocessorLine
-	| ERROR TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveError(); }   #preprocessorDiagnostic
-	| WARNING TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveWarning(); }   #preprocessorDiagnostic
-	| REGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveRegion(); }   #preprocessorRegion
-	| ENDREGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndregion(); }   #preprocessorRegion
-	| PRAGMA TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectivePragma(); }   #preprocessorPragma
-	| NULLABLE TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveNullable(); }   #preprocessorNullable
+	: DEFINE CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.onPreprocessorDirectiveDefine(); }  #preprocessorDeclaration
+	| UNDEF CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.onPreprocessorDirectiveUndef(); } #preprocessorDeclaration
+	| IF expr=preprocessor_expression directive_new_line_or_sharp { this.onPreprocessorDirectiveIf(); }	  #preprocessorConditional
+	| ELIF expr=preprocessor_expression directive_new_line_or_sharp { this.onPreprocessorDirectiveElif(); } #preprocessorConditional
+	| ELSE directive_new_line_or_sharp { this.onPreprocessorDirectiveElse(); }    #preprocessorConditional
+	| ENDIF directive_new_line_or_sharp { this.onPreprocessorDirectiveEndif(); } #preprocessorConditional
+	| LINE (DIGITS STRING? | DEFAULT | DIRECTIVE_HIDDEN) directive_new_line_or_sharp { this.onPreprocessorDirectiveLine(); } #preprocessorLine
+	| ERROR TEXT directive_new_line_or_sharp { this.onPreprocessorDirectiveError(); }   #preprocessorDiagnostic
+	| WARNING TEXT directive_new_line_or_sharp { this.onPreprocessorDirectiveWarning(); }   #preprocessorDiagnostic
+	| REGION TEXT? directive_new_line_or_sharp { this.onPreprocessorDirectiveRegion(); }   #preprocessorRegion
+	| ENDREGION TEXT? directive_new_line_or_sharp { this.onPreprocessorDirectiveEndregion(); }   #preprocessorRegion
+	| PRAGMA TEXT directive_new_line_or_sharp { this.onPreprocessorDirectivePragma(); }   #preprocessorPragma
+	| NULLABLE TEXT directive_new_line_or_sharp { this.onPreprocessorDirectiveNullable(); }   #preprocessorNullable
 	;
 
 directive_new_line_or_sharp
@@ -28,13 +28,13 @@ directive_new_line_or_sharp
     ;
 
 preprocessor_expression returns [String value]
-	: TRUE { this.OnPreprocessorExpressionTrue(); }
-	| FALSE { this.OnPreprocessorExpressionFalse(); }
-	| CONDITIONAL_SYMBOL { this.OnPreprocessorExpressionConditionalSymbol(); }
-	| OPEN_PARENS expr=preprocessor_expression CLOSE_PARENS { this.OnPreprocessorExpressionConditionalOpenParens(); }
-	| BANG expr=preprocessor_expression { this.OnPreprocessorExpressionConditionalBang(); }
-	| expr1=preprocessor_expression OP_EQ expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalEq(); }
-	| expr1=preprocessor_expression OP_NE expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalNe(); }
-	| expr1=preprocessor_expression OP_AND expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalAnd(); }
-	| expr1=preprocessor_expression OP_OR expr2=preprocessor_expression { this.OnPreprocessorExpressionConditionalOr(); }
+	: TRUE { this.onPreprocessorExpressionTrue(); }
+	| FALSE { this.onPreprocessorExpressionFalse(); }
+	| CONDITIONAL_SYMBOL { this.onPreprocessorExpressionConditionalSymbol(); }
+	| OPEN_PARENS expr=preprocessor_expression CLOSE_PARENS { this.onPreprocessorExpressionConditionalOpenParens(); }
+	| BANG expr=preprocessor_expression { this.onPreprocessorExpressionConditionalBang(); }
+	| expr1=preprocessor_expression OP_EQ expr2=preprocessor_expression { this.onPreprocessorExpressionConditionalEq(); }
+	| expr1=preprocessor_expression OP_NE expr2=preprocessor_expression { this.onPreprocessorExpressionConditionalNe(); }
+	| expr1=preprocessor_expression OP_AND expr2=preprocessor_expression { this.onPreprocessorExpressionConditionalAnd(); }
+	| expr1=preprocessor_expression OP_OR expr2=preprocessor_expression { this.onPreprocessorExpressionConditionalOr(); }
 	;

+ 12 - 11
jplag.frontend.csharp-6/src/main/java/de/jplag/csharp/grammar/CSharpLexerBase.java

@@ -2,7 +2,8 @@ package de.jplag.csharp.grammar;
 
 import java.util.Stack;
 
-import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Lexer;
 
 /**
  * This class was taken from <a href="https://github.com/antlr/grammars-v4/tree/master/csharp">antlr/grammars-v4</a>. It
@@ -18,25 +19,25 @@ abstract class CSharpLexerBase extends Lexer {
     protected Stack<Integer> curlyLevels = new Stack<>();
     protected boolean verbatium;
 
-    protected void OnInterpolatedRegularStringStart() {
+    protected void onInterpolatedRegularStringStart() {
         interpolatedStringLevel++;
         interpolatedVerbatiums.push(false);
         verbatium = false;
     }
 
-    protected void OnInterpolatedVerbatiumStringStart() {
+    protected void onInterpolatedVerbatiumStringStart() {
         interpolatedStringLevel++;
         interpolatedVerbatiums.push(true);
         verbatium = true;
     }
 
-    protected void OnOpenBrace() {
+    protected void onOpenBrace() {
         if (interpolatedStringLevel > 0) {
             curlyLevels.push(curlyLevels.pop() + 1);
         }
     }
 
-    protected void OnCloseBrace() {
+    protected void onCloseBrace() {
 
         if (interpolatedStringLevel > 0) {
             curlyLevels.push(curlyLevels.pop() - 1);
@@ -48,7 +49,7 @@ abstract class CSharpLexerBase extends Lexer {
         }
     }
 
-    protected void OnColon() {
+    protected void onColon() {
         if (interpolatedStringLevel > 0) {
             int ind = 1;
             boolean switchToFormatString = true;
@@ -65,25 +66,25 @@ abstract class CSharpLexerBase extends Lexer {
         }
     }
 
-    protected void OpenBraceInside() {
+    protected void openBraceInside() {
         curlyLevels.push(1);
     }
 
-    protected void OnDoubleQuoteInside() {
+    protected void onDoubleQuoteInside() {
         interpolatedStringLevel--;
         interpolatedVerbatiums.pop();
         verbatium = (interpolatedVerbatiums.size() > 0 ? interpolatedVerbatiums.peek() : false);
     }
 
-    protected void OnCloseBraceInside() {
+    protected void onCloseBraceInside() {
         curlyLevels.pop();
     }
 
-    protected boolean IsRegularCharInside() {
+    protected boolean isRegularCharInside() {
         return !verbatium;
     }
 
-    protected boolean IsVerbatiumDoubleQuoteInside() {
+    protected boolean isVerbatiumDoubleQuoteInside() {
         return verbatium;
     }
 }

+ 1 - 1
jplag.frontend.csharp-6/src/main/java/de/jplag/csharp/grammar/CSharpParserBase.java

@@ -15,7 +15,7 @@ public abstract class CSharpParserBase extends Parser {
         super(input);
     }
 
-    protected boolean IsLocalVariableDeclaration() {
+    protected boolean isLocalVariableDeclaration() {
         Local_variable_declarationContext localVariable = (Local_variable_declarationContext) this._ctx;
         if (localVariable == null)
             return true;

+ 41 - 41
jplag.frontend.csharp-6/src/main/java/de/jplag/csharp/grammar/CSharpPreprocessorParserBase.java

@@ -26,162 +26,162 @@ abstract class CSharpPreprocessorParserBase extends Parser {
     private static final String TRUE = Boolean.toString(true);
     private static final String DEBUG = "DEBUG";
 
-    private Stack<Boolean> conditions = new Stack<>();
-    private HashSet<String> ConditionalSymbols = new HashSet<>();
+    private final Stack<Boolean> conditions = new Stack<>();
+    private final HashSet<String> conditionalSymbols = new HashSet<>();
 
     protected CSharpPreprocessorParserBase(TokenStream input) {
         super(input);
         conditions.push(true);
-        ConditionalSymbols.add(DEBUG);
+        conditionalSymbols.add(DEBUG);
     }
 
-    protected Boolean AllConditions() {
+    protected Boolean allConditions() {
         return conditions.stream().allMatch(it -> it);
     }
 
-    protected void OnPreprocessorDirectiveDefine() {
+    protected void onPreprocessorDirectiveDefine() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorDeclarationContext context = (PreprocessorDeclarationContext) ruleContext;
-        ConditionalSymbols.add(context.CONDITIONAL_SYMBOL().getText());
-        context.value = AllConditions();
+        conditionalSymbols.add(context.CONDITIONAL_SYMBOL().getText());
+        context.value = allConditions();
     }
 
-    protected void OnPreprocessorDirectiveUndef() {
+    protected void onPreprocessorDirectiveUndef() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorDeclarationContext context = (PreprocessorDeclarationContext) ruleContext;
-        ConditionalSymbols.remove(context.CONDITIONAL_SYMBOL().getText());
-        context.value = AllConditions();
+        conditionalSymbols.remove(context.CONDITIONAL_SYMBOL().getText());
+        context.value = allConditions();
     }
 
-    protected void OnPreprocessorDirectiveIf() {
+    protected void onPreprocessorDirectiveIf() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorConditionalContext context = (PreprocessorConditionalContext) ruleContext;
-        context.value = context.expr.value.equals(TRUE) && AllConditions();
+        context.value = context.expr.value.equals(TRUE) && allConditions();
         conditions.push(context.expr.value.equals(TRUE));
     }
 
-    protected void OnPreprocessorDirectiveElif() {
+    protected void onPreprocessorDirectiveElif() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorConditionalContext context = (PreprocessorConditionalContext) ruleContext;
         if (Boolean.FALSE.equals(conditions.peek())) {
             conditions.pop();
-            context.value = context.expr.value.equals(TRUE) && AllConditions();
+            context.value = context.expr.value.equals(TRUE) && allConditions();
             conditions.push(context.expr.value.equals(TRUE));
         } else {
             context.value = false;
         }
     }
 
-    protected void OnPreprocessorDirectiveElse() {
+    protected void onPreprocessorDirectiveElse() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorConditionalContext context = (PreprocessorConditionalContext) ruleContext;
         if (Boolean.FALSE.equals(conditions.peek())) {
             conditions.pop();
-            context.value = AllConditions();
+            context.value = allConditions();
             conditions.push(true);
         } else {
             context.value = false;
         }
     }
 
-    protected void OnPreprocessorDirectiveEndif() {
+    protected void onPreprocessorDirectiveEndif() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorConditionalContext context = (PreprocessorConditionalContext) ruleContext;
         conditions.pop();
         context.value = conditions.peek();
     }
 
-    protected void OnPreprocessorDirectiveLine() {
+    protected void onPreprocessorDirectiveLine() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorLineContext context = (PreprocessorLineContext) ruleContext;
-        context.value = AllConditions();
+        context.value = allConditions();
     }
 
-    protected void OnPreprocessorDirectiveError() {
+    protected void onPreprocessorDirectiveError() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorDiagnosticContext context = (PreprocessorDiagnosticContext) ruleContext;
-        context.value = AllConditions();
+        context.value = allConditions();
     }
 
-    protected void OnPreprocessorDirectiveWarning() {
+    protected void onPreprocessorDirectiveWarning() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorDiagnosticContext context = (PreprocessorDiagnosticContext) ruleContext;
-        context.value = AllConditions();
+        context.value = allConditions();
     }
 
-    protected void OnPreprocessorDirectiveRegion() {
+    protected void onPreprocessorDirectiveRegion() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorRegionContext context = (PreprocessorRegionContext) ruleContext;
-        context.value = AllConditions();
+        context.value = allConditions();
     }
 
-    protected void OnPreprocessorDirectiveEndregion() {
+    protected void onPreprocessorDirectiveEndregion() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorRegionContext context = (PreprocessorRegionContext) ruleContext;
-        context.value = AllConditions();
+        context.value = allConditions();
     }
 
-    protected void OnPreprocessorDirectivePragma() {
+    protected void onPreprocessorDirectivePragma() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorPragmaContext context = (PreprocessorPragmaContext) ruleContext;
-        context.value = AllConditions();
+        context.value = allConditions();
     }
 
-    protected void OnPreprocessorDirectiveNullable() {
+    protected void onPreprocessorDirectiveNullable() {
         ParserRuleContext ruleContext = this._ctx;
         PreprocessorNullableContext context = (PreprocessorNullableContext) ruleContext;
-        context.value = AllConditions();
+        context.value = allConditions();
     }
 
-    protected void OnPreprocessorExpressionTrue() {
+    protected void onPreprocessorExpressionTrue() {
         ParserRuleContext ruleContext = this._ctx;
         Preprocessor_expressionContext context = (Preprocessor_expressionContext) ruleContext;
         context.value = TRUE;
     }
 
-    protected void OnPreprocessorExpressionFalse() {
+    protected void onPreprocessorExpressionFalse() {
         ParserRuleContext ruleContext = this._ctx;
         Preprocessor_expressionContext context = (Preprocessor_expressionContext) ruleContext;
         context.value = FALSE;
     }
 
-    protected void OnPreprocessorExpressionConditionalSymbol() {
+    protected void onPreprocessorExpressionConditionalSymbol() {
         ParserRuleContext ruleContext = this._ctx;
         Preprocessor_expressionContext context = (Preprocessor_expressionContext) ruleContext;
-        context.value = ConditionalSymbols.contains(context.CONDITIONAL_SYMBOL().getText()) ? TRUE : FALSE;
+        context.value = conditionalSymbols.contains(context.CONDITIONAL_SYMBOL().getText()) ? TRUE : FALSE;
     }
 
-    protected void OnPreprocessorExpressionConditionalOpenParens() {
+    protected void onPreprocessorExpressionConditionalOpenParens() {
         ParserRuleContext ruleContext = this._ctx;
         Preprocessor_expressionContext context = (Preprocessor_expressionContext) ruleContext;
         context.value = context.expr.value;
     }
 
-    protected void OnPreprocessorExpressionConditionalBang() {
+    protected void onPreprocessorExpressionConditionalBang() {
         ParserRuleContext ruleContext = this._ctx;
         Preprocessor_expressionContext context = (Preprocessor_expressionContext) ruleContext;
         context.value = context.expr.value.equals(TRUE) ? FALSE : TRUE;
     }
 
-    protected void OnPreprocessorExpressionConditionalEq() {
+    protected void onPreprocessorExpressionConditionalEq() {
         ParserRuleContext ruleContext = this._ctx;
         Preprocessor_expressionContext context = (Preprocessor_expressionContext) ruleContext;
         context.value = (Objects.equals(context.expr1.value, context.expr2.value) ? TRUE : FALSE);
     }
 
-    protected void OnPreprocessorExpressionConditionalNe() {
+    protected void onPreprocessorExpressionConditionalNe() {
         ParserRuleContext ruleContext = this._ctx;
         Preprocessor_expressionContext context = (Preprocessor_expressionContext) ruleContext;
         context.value = (!Objects.equals(context.expr1.value, context.expr2.value) ? TRUE : FALSE);
     }
 
-    protected void OnPreprocessorExpressionConditionalAnd() {
+    protected void onPreprocessorExpressionConditionalAnd() {
         ParserRuleContext ruleContext = this._ctx;
         Preprocessor_expressionContext context = (Preprocessor_expressionContext) ruleContext;
         context.value = (context.expr1.value.equals(TRUE) && context.expr2.value.equals(TRUE) ? TRUE : FALSE);
     }
 
-    protected void OnPreprocessorExpressionConditionalOr() {
+    protected void onPreprocessorExpressionConditionalOr() {
         ParserRuleContext ruleContext = this._ctx;
         Preprocessor_expressionContext context = (Preprocessor_expressionContext) ruleContext;
         context.value = (context.expr1.value.equals(TRUE) || context.expr2.value.equals(TRUE) ? TRUE : FALSE);