<commit_before>grammar Hekate;

/*
 * Parser Rules
 */

script
	:	(functionDeclaration|emitterUpdaterDeclaration|bulletUpdaterDeclaration)*
	;
	
variableDeclaration
	:	VAR NormalIdentifier ASSIGN expression
	;
	
functionDeclaration
	:	FUNCTION NormalIdentifier formalParameters functionBody
	;

emitterUpdaterDeclaration
	:	EUPDATER NormalIdentifier formalParameters updaterBody
	;

bulletUpdaterDeclaration
	:	BUPDATER NormalIdentifier formalParameters updaterBody
	;

functionBody
	:	blockWithReturn
	;

updaterBody
	:	block
	;

block
	:	LBRACE statement* RBRACE
	;

blockWithReturn
	:	LBRACE (statement|returnStatement)* RBRACE
	;

formalParameter
	:	NormalIdentifier
	;

formalParameterList
	:	formalParameter (COMMA formalParameter)*
	;

formalParameters
	:	LPAREN formalParameterList? RPAREN
	;

// statements
statement
	:	block	# BlockStatement
	|	IF parExpression statement (ELSE statement)?		# IfStatement
	|	FOR LPAREN forControl RPAREN statement				# ForStatement
	|	WHILE parExpression statement						# WhileStatement
	|	BREAK SEMI				# BreakStatement
	|	CONTINUE SEMI			# ContinueStatement
	|	SEMI					# EmptyStatement
	|	VAR NormalIdentifier ASSIGN createEmitterExpression SEMI	# CreateEmitterVariableStatement
	|	VAR NormalIdentifier ASSIGN buildEmitterExpression SEMI	# BuildEmitterVariableStatement
	|	variableDeclaration SEMI							# VariableDeclarationStatement
	|	expression SEMI			# ExpressionStatement
	|	NormalIdentifier ATTACH NormalIdentifier parExpressionList withUpdaterOption? SEMI		# AttachEmitterStatement
	|	FIRE NormalIdentifier parExpressionList fromEmitterOption SEMI	# FireStatement
	|	WAIT expression FRAMES SEMI		# WaitStatement
	;

returnStatement
	:	RETURN expression SEMI
	;
		
fromEmitterOption
	:	FROM NormalIdentifier
	;

forControl
	:	forInit? SEMI expression? SEMI forUpdate
	;

forInit
	:	variableDeclaration
	|	expressionList
	;

forUpdate
	:	expressionList
	;	

// expressions
parExpression
	:	LPAREN expression RPAREN
	;

expressionList
	:	expression (COMMA expression)*
	;

parExpressionList
	:	LPAREN expressionList? RPAREN
	;

updaterCallExpression
	:	NormalIdentifier parExpressionList
	;

createEmitterExpression
	:	CREATE EMITTER parExpressionList withUpdaterOption?
	;

buildEmitterExpression
	:	BUILD NormalIdentifier
	;

withUpdaterOption
	:	WITH UPDATER updaterCallExpression
	;

expression
	:	LPAREN expression RPAREN	# ParenthesizedExpression
	|	Literal						# LiteralExpression
	|	NormalIdentifier			        # NormalIdentifierExpression
	|	PropertyIdentifier					# PropertyIdentifierExpression
	|	expression Operator=(INC|DEC)		# PostIncDecExpression
	|	Operator=(
			SUB
		|	BANG
		)
		expression	# UnaryExpression
	|	expression
		Operator=(
			MUL 
		|	DIV
		|	MOD
		|	ADD
		|	SUB
		|	LE
		|	GE
		|	LT
		|	GT
		|	EQUAL
		|	NOTEQUAL
		|	AND<commit_msg>Updates the PostIncDecExpression lexer entry a bit. Now you can only attempt to inc/decrement local variables or properties.<commit_after>grammar Hekate;

/*
 * Parser Rules
 */

script
	:	(functionDeclaration|emitterUpdaterDeclaration|bulletUpdaterDeclaration)*
	;
	
variableDeclaration
	:	VAR NormalIdentifier ASSIGN expression
	;
	
functionDeclaration
	:	FUNCTION NormalIdentifier formalParameters functionBody
	;

emitterUpdaterDeclaration
	:	EUPDATER NormalIdentifier formalParameters updaterBody
	;

bulletUpdaterDeclaration
	:	BUPDATER NormalIdentifier formalParameters updaterBody
	;

functionBody
	:	blockWithReturn
	;

updaterBody
	:	block
	;

block
	:	LBRACE statement* RBRACE
	;

blockWithReturn
	:	LBRACE (statement|returnStatement)* RBRACE
	;

formalParameter
	:	NormalIdentifier
	;

formalParameterList
	:	formalParameter (COMMA formalParameter)*
	;

formalParameters
	:	LPAREN formalParameterList? RPAREN
	;

// statements
statement
	:	block	# BlockStatement
	|	IF parExpression statement (ELSE statement)?		# IfStatement
	|	FOR LPAREN forControl RPAREN statement				# ForStatement
	|	WHILE parExpression statement						# WhileStatement
	|	BREAK SEMI				# BreakStatement
	|	CONTINUE SEMI			# ContinueStatement
	|	SEMI					# EmptyStatement
	|	VAR NormalIdentifier ASSIGN createEmitterExpression SEMI	# CreateEmitterVariableStatement
	|	VAR NormalIdentifier ASSIGN buildEmitterExpression SEMI	# BuildEmitterVariableStatement
	|	variableDeclaration SEMI							# VariableDeclarationStatement
	|	expression SEMI			# ExpressionStatement
	|	NormalIdentifier ATTACH NormalIdentifier parExpressionList withUpdaterOption? SEMI		# AttachEmitterStatement
	|	FIRE NormalIdentifier parExpressionList fromEmitterOption SEMI	# FireStatement
	|	WAIT expression FRAMES SEMI		# WaitStatement
	;

returnStatement
	:	RETURN expression SEMI
	;
		
fromEmitterOption
	:	FROM NormalIdentifier
	;

forControl
	:	forInit? SEMI expression? SEMI forUpdate
	;

forInit
	:	variableDeclaration
	|	expressionList
	;

forUpdate
	:	expressionList
	;	

// expressions
parExpression
	:	LPAREN expression RPAREN
	;

expressionList
	:	expression (COMMA expression)*
	;

parExpressionList
	:	LPAREN expressionList? RPAREN
	;

updaterCallExpression
	:	NormalIdentifier parExpressionList
	;

createEmitterExpression
	:	CREATE EMITTER parExpressionList withUpdaterOption?
	;

buildEmitterExpression
	:	BUILD NormalIdentifier
	;

withUpdaterOption
	:	WITH UPDATER updaterCallExpression
	;

expression
	:	LPAREN expression RPAREN	# ParenthesizedExpression
	|	Literal						# LiteralExpression
	|	NormalIdentifier			        # NormalIdentifierExpression
	|	PropertyIdentifier					# PropertyIdentifierExpression
	|	(NormalIdentifier|PropertyIdentifier) Operator=(INC|DEC)		# PostIncDecExpression
	|	Operator=(
			SUB
		|	BANG
		)
		expression	# UnaryExpression
	|	expression
		Operator=(
			MUL 
		|	DIV
		|	MOD
		|	ADD
		|	SUB
		|	LE
		|	GE
		|	LT
		|	GT
		|	EQUAL
		|	NOTEQUAL
		|	AND
{'fraction_non_alphanumeric': 0.05305131761442441, 'fraction_numerical': 0.0, 'mean_word_length': 4.706231454005935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2111838', 'n_tokens_mistral': 1939, 'n_tokens_neox': 1822, 'n_words': 398}