<commit_before>grammar Noop;

options {
  output = AST;
  ASTLabelType = CommonTree;
}

tokens {
  CLASS;
  INTERFACE;
  PARAMS;
  PARAM;
  METHOD;
  MOD;
  ARGS;
  VAR;
  IMPL;
}

@header {
  package noop.grammar.antlr;
}

@lexer::header {
  package noop.grammar.antlr;
}

@rulecatch {
  catch (RecognitionException e) { 
    reportError(e);
    throw e;
  }
}

// A line of user input in the interactive interpreter
interpretable
  :	(importDeclaration 
     | classDeclaration
     | statement)+
	;

file
	:	namespaceDeclaration? importDeclaration* (classDeclaration | interfaceDeclaration)
	;

namespaceDeclaration
	:	'namespace'^ namespace ';'!
	;

importDeclaration
	:	'import'^ qualifiedType ';'!
	;

methodDeclaration
	: methodSignature block
	-> ^(METHOD methodSignature block)
	;

namespace
	:	VariableIdentifier ('.'! VariableIdentifier)*
	;

qualifiedType
	:	 (namespace '.'!)? TypeIdentifier
	;

classDeclaration
	: modifiers? 'class' TypeIdentifier parameterList typeSpecifiers? classBlock
	-> ^(CLASS modifiers? TypeIdentifier parameterList? typeSpecifiers? classBlock?)
	;

typeSpecifiers
	: 'implements' qualifiedType (',' qualifiedType)*
	-> ^(IMPL qualifiedType)*
	;

interfaceDeclaration
  : 'interface' TypeIdentifier interfaceBlock
  -> ^(INTERFACE TypeIdentifier interfaceBlock?)
  ;

modifiers
	: modifier+
	-> ^(MOD modifier+)
	;

modifier
	: 'mutable' | 'delegate' | 'native'
	;

classBlock
	:	'{'!  identifierDeclaration* methodDeclaration* '}'!
	;

interfaceBlock
  : '{'! methodDefinition* '}'!
	;

methodSignature
  : modifiers? TypeIdentifier VariableIdentifier parameterList
  ;

methodDefinition
  : methodSignature ';'
  -> ^(METHOD methodSignature)
  ;


identifierDeclaration
	:	TypeIdentifier identifierDeclarator ';'
	-> ^(VAR TypeIdentifier identifierDeclarator)
	;

identifierDeclarator
	: VariableIdentifier ('='^ expression)?
	;

block
	: '{'!  statement* '}'!
	;

statement
	:	identifierDeclaration
	| 'return'^ expression ';'!
	| expression ';'!
	;

expression
	: primary ('='^ expression)?
	;
	
primary
	:	'('! expression ')'!
	| (VariableIdentifier|TypeIdentifier|literal) ('.'^ (VariableIdentifier|TypeIdentifier) arguments?)*
	;
	
arguments
	:	'(' expressionList? ')'
	-> ^(ARGS expressionList?)
	;

expressionList
	:	expression (','! expression)*
	;

parameterList
	: '('! parameters? ')'!
	;

parameters
	: parameter (',' parameter)*
	-> ^(PARAMS parameter*)
	;

parameter
	: modifiers? TypeIdentifier VariableIdentifier
	-> ^(PARAM modifiers? TypeIdentifier VariableIdentifier)
	;

literal
	: INT | StringLiteral
	;

/* Lexer rules */

TypeIdentifier
	: 'A' .. 'Z' ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9')*
	;

VariableIdentifier
	: 'a' .. 'z' ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9')*
	;

StringLiteral
	:	'"' ~('\\'|'"')* '"'
	;

	
WS
  :	(' '|'\r'|'\n')+ {$channel = HIDDEN;} 
  ;

COMMENT
  :   '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
  ;

LINE_COMMENT
  : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
  ;

INT
	:	'-'? '0'..'9'+
	;
<commit_msg>Allow empty blocks for method declarations.<commit_after>// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

grammar Noop;

options {
  output = AST;
  ASTLabelType = CommonTree;
}

tokens {
  CLASS;
  INTERFACE;
  PARAMS;
  PARAM;
  METHOD;
  MOD;
  ARGS;
  VAR;
  IMPL;
}

@header {
  package noop.grammar.antlr;
}

@lexer::header {
  package noop.grammar.antlr;
}

@rulecatch {
  catch (RecognitionException e) {
    reportError(e);
    throw e;
  }
}

// A line of user input in the interactive interpreter
interpretable
  :	(importDeclaration
     | classDeclaration
     | statement)+
	;

file
	:	namespaceDeclaration? importDeclaration* (classDeclaration | interfaceDeclaration)
	;

namespaceDeclaration
	:	'namespace'^ namespace ';'!
	;

importDeclaration
	:	'import'^ qualifiedType ';'!
	;

methodDeclaration
	: methodSignature block
	-> ^(METHOD methodSignature block?)
	;

namespace
	:	VariableIdentifier ('.'! VariableIdentifier)*
	;

qualifiedType
	:	 (namespace '.'!)? TypeIdentifier
	;

classDeclaration
	: modifiers? 'class' TypeIdentifier parameterList typeSpecifiers? classBlock
	-> ^(CLASS modifiers? TypeIdentifier parameterList? typeSpecifiers? classBlock?)
	;

typeSpecifiers
	: 'implements' qualifiedType (',' qualifiedType)*
	-> ^(IMPL qualifiedType)*
	;

interfaceDeclaration
  : 'interface' TypeIdentifier interfaceBlock
  -> ^(INTERFACE TypeIdentifier interfaceBlock?)
  ;

modifiers
	: modifier+
	-> ^(MOD modifier+)
	;

modifier
	: 'mutable' | 'delegate' | 'native'
	;

classBlock
	:	'{'!  identifierDeclaration* methodDeclaration* '}'!
	;

interfaceBlock
  : '{'! methodDefinition* '}'!
	;

methodSignature
  : modifiers? TypeIdentifier VariableIdentifier parameterList
  ;

methodDefinition
  : methodSignature ';'
  -> ^(METHOD methodSignature)
  ;


identifierDeclaration
	:	TypeIdentifier identifierDeclarator ';'
	-> ^(VAR TypeIdentifier identifierDeclarator)
	;

identifierDeclarator
	: VariableIdentifier ('='^ expression)?
	;

block
	: '{'!  statement* '}'!
	;

statement
	:	identifierDeclaration
	| 'return'^ expression ';'!
	| expression ';'!
	;

expression
	: primary ('='^ expression)?
	;

primary
	:	'('! expression ')'!
	| (VariableIdentifier|TypeIdentifier|literal) ('.'^ (VariableIdentifier|TypeIdentifier) arguments?)*
	;

arguments
	:	'(' expressionList? ')'
	-> ^(ARGS expressionList?)
	;

expressionList
	:	expression (','! expression)*
	;

parameterList
	: '('! parameters? ')'!
	;

parameters
	: parameter (',' parameter)*
	-> ^(PARAMS parameter*)
	;

parameter
	: modifiers? TypeIdentifier VariableIdentifier
	-> ^(PARAM modifiers? TypeIdentifier VariableIdentifier)
	;

literal
	: INT | StringLiteral
	;

/* Lexer rules */

TypeIdentifier
	: 'A' .. 'Z' ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9')*
	;

VariableIdentifier
	: 'a' .. 'z' ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9')*
	;

StringLiteral
	:	'"' ~('\\'|'"')* '"'
	;


WS
  :	(' '|'\r'|'\n')+ {$channel = HIDDEN;}
  ;

COMMENT
  :   '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
  ;

LINE_COMMENT
  : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
  ;

INT
	:	'-'? '0'..'9'+
	;

{'fraction_non_alphanumeric': 0.16240985576923078, 'fraction_numerical': 0.0030048076923076925, 'mean_word_length': 3.8948529411764707, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5964749', 'n_tokens_mistral': 2341, 'n_tokens_neox': 2274, 'n_words': 486}