Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- psiClassPrefix = "Corona"
- elementTypeHolderClass="com.gameforge.idea.Corona.lang.parser.CoronaElementTypes"
- elementTypeClass="com.gameforge.idea.Corona.lang.lexer.CoronaElementType"
- tokenTypeClass="com.gameforge.idea.Corona.lang.lexer.CoronaElementType"
- implements = "com.gameforge.idea.Corona.lang.psi.CoronaPsiElement"
- extends = "com.gameforge.idea.Corona.lang.psi.impl.CoronaPsiElementImpl"
- psiVisitorName="CoronaVisitor"
- psiPackage="com.gameforge.idea.Corona.lang.psi"
- psiImplPackage="com.gameforge.idea.Corona.lang.psi.impl"
- }
- // Finding 1: there has to be an empty rule, because Grammar-kit, for whatever reason, deletes the first rule.
- // unused ::= String
- // Finding 2: apparently, if you put an empty rule in here, the code won't work. The first rule is not created as a PSI Object but still used as the root File node by the parser
- Root ::= Block
- Block ::= BlockStatement | BlockLastStatement
- private BlockStatement ::= Statements Statements* [LastStatement]
- private BlockLastStatement ::= Statements* LastStatement
- //#################################################################
- //#################### Statements & Variables #####################
- //#################################################################
- Statements ::= (FunctionDeclaration | Assignment | expressionStatement | Declaration | ForLoop | WhileLoop | RepeatLoop | If | ClassOOP) [LineEnding]
- LastStatement ::= returnState | break
- private returnState ::= return (Statements | Expression) //{pin=1}
- ChainedCall ::= (ChainedFunctionCall | ChainedVariableCall) index
- ChainedVariableCall ::= PreCall Variable
- ChainedFunctionCall ::= PreCall FunctionCall
- private call ::= (funcCall | varCall) index
- PreChainedVariable ::= (ClassVariable | simpleVarChain) FunctionCallToken
- private simpleVarChain ::= Identifier (FunctionCallToken Identifier &FunctionCallToken)*
- private index ::= ('[' Expression ']')*
- Variable ::= (Identifier | ThisIdentifier) index !('(' | FunctionCallToken | ',')
- ClassVariable ::= ClassField [PreChainedVariable]
- Declaration ::= [local] (VariableList | varCall)
- TableConstructor ::= '{' [ExpressionList] '}'
- Assignment ::= Declaration '=' (ExpressionList | Expression)
- VariableList ::= varCall ',' varCall (',' varCall)* //{recoverWhile="Assignment"}
- private varCall ::= ChainedVariableCall | Variable
- private funcCall ::= ChainedFunctionCall | FunctionCall
- ThisIdentifier ::= this {
- mixin="com.gameforge.idea.Corona.lang.psi.impl.CoronaPsiNamedElementImpl"
- methods=[ getIdentifier="ThisIdentifier" getNameIdentifier="ThisIdentifier" getName setName]
- }
- Identifier ::= Name {
- mixin="com.gameforge.idea.Corona.lang.psi.impl.CoronaPsiNamedElementImpl"
- methods=[ getIdentifier="Identifier" getNameIdentifier="Identifier" getName setName]
- }
- ClassIdentifier ::= Class {
- mixin="com.gameforge.idea.Corona.lang.psi.impl.CoronaPsiNamedElementImpl"
- methods=[ getIdentifier="ClassIdentifier" getNameIdentifier="ClassIdentifier" getName setName]
- }
- //####################################################
- //#################### Functions #####################
- //####################################################
- private functionBracketsOpen ::= '(' | '{'
- private functionBracketsClose ::= ')' | '}'
- IdentifierList ::= Identifier (',' Identifier)*
- ParameterList ::= IdentifierList [',' '...'] | '...'
- FunctionDeclaration ::= [local] function functionName functionBody end
- AnonymousFunction ::= [local] function functionBody end
- private functionParameter ::= '(' [ParameterList] ')' | '(' ThisIdentifier ')'
- private functionBody ::= functionParameter [Block] {pin=1}
- private functionName ::= [PreChainedVariable] Identifier
- //private preFuncName ::= ClassField [simpleVarChain] FunctionCallToken
- FunctionCall ::= Identifier functionBracketsOpen [ExpressionList] functionBracketsClose
- ForLoop ::= for LoopExpression LoopBody
- WhileLoop ::= while Expression LoopBody
- RepeatLoop ::= repeat [Block] until Expression
- LoopBody ::= do [Block] end
- LoopExpression ::= Identifier '=' Expression ',' Expression [',' Expression] | IdentifierList in ExpressionList
- //####################################################
- //################### expression #####################
- //####################################################
- ExpressionList ::= Expression ',' Expression (',' Expression)*
- Expression ::= (ExpressionValues | AnonymousFunction | RequireBlock | Assignment | PrefixExpression | TableConstructor | UnaryOperator Expression | boolExpression) [OperatorExpression]
- private expressionStatement ::= RequireStatement | funcCall index | TableConstructor | boolExpression | UnaryOperator Expression
- OperatorExpression ::= BinaryOperator Expression
- PrefixExpression ::= ChainedCall | '(' Expression ')'
- If ::= if Expression then Block (elseif Expression then Block)* [else Block] end
- RequireBlock ::= require '(' requireParameter ')'
- private requireParameter ::= (ExpressionValues | ChainedCall) ['..' (ExpressionValues | ChainedCall)]
- PreCall ::= preCallPart preCallPart*
- private preCallPart ::= (PreChainedVariable | FunctionCall FunctionCallToken | '(' Expression ')' FunctionCallToken | Variable FunctionCallToken)
- private boolExpression ::= call and boolExpressionReturnValue or boolExpressionReturnValue
- private boolExpressionReturnValue ::= (call | ExpressionValues)
- //####################################################
- //###################### Class #######################
- //####################################################
- private visibilityTable ::= '.' Visibility {pin=1}
- Visibility ::= public | private | protected
- ClassField ::= ThisIdentifier [visibilityTable]
- RequireStatement ::= (Identifier | ClassIdentifier) '=' RequireBlock
- ClassOOP ::= ClassIdentifier ':' (ClassCreateFunction | ClassExtendFunction)
- ClassCreateFunction ::= create '(' AnonymousFunction ')'
- ClassExtendFunction ::= extend '(' ClassParent ',' AnonymousFunction ')'
- ClassParent ::= Path | ChainedCall
- //####################################################
- //###################### Token #######################
- //####################################################
- private LineEnding ::= ';'
- BinaryOperator ::= '+' | '-' | '*' | '/' | '^' | '%' | '..' | '<' | '<=' | '>' | '>=' | '==' | '~=' | and | or
- UnaryOperator ::= '-' | not | '#'
- FieldSeparator ::= ',' | ';'
- FunctionCallToken ::= '.' | ':'
- ExpressionValues ::= nil | false | true | Number | String String* | '...' | Path
- Path ::= '"' String ('.' String)* '"'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement