[Cuis-dev] [Haver] Grammar for Cuis 7.0

Gerald Klix cuis.01 at klix.ch
Fri Sep 20 07:05:49 PDT 2024


Hi,

Finally I managed to complete a Grammar for Cuis 7.0.
It can parse the 30001 methods in the development image
of my Early-Parser package. Alas I do not know,
if it creates the right syntax trees.

The grammar has to start symbols,
`method` for – who guessed it – methods
and `body` for "doit" code.

Please, see at Haver's Mastodon account for a screenshot:
https://troet.cafe/@Haver/113170219713751275


HTH and Best Regards,

Gerald


Grammar Text:
	method → methodPattern, pragmas, localVariableDefintions, pragmas, pureBody.
	method → methodPattern, localVariableDefintions, pragmas, pureBody.
	method → methodPattern, pragmas, localVariableDefintions, pureBody.
	method → methodPattern, εlocalVariableDefintions, pureBody.
	method → methodPattern, pragmas, pureBody.

        body → εlocalVariableDefintions, pureBody.
	
	methodPattern → #word.
	methodPattern → binaryOperator, #word.
	methodPattern → keywordParameters.
	
	εlocalVariableDefintions → ε.
	εlocalVariableDefintions → localVariableDefintions.
	localVariableDefintions → #verticalBar, variables, #verticalBar	.
	variables → ε.
	variables → variables, #word.
	
	pragmas → pragma.
	pragmas → pragmas, pragma.
	pragma → #binary ∈ #(<), pragmaDefinition, #binary ∈ #(>).
	pragmaDefinition → #word.
	pragmaDefinition → keywordPragmaDefinition.
	keywordPragmaDefinition → #keyword, terminalExpression.
	keywordPragmaDefinition → keywordPragmaDefinition, #keyword, terminalExpression.		
	
	keywordParameters → keywordParameter.
	keywordParameters → keywordParameters, keywordParameter.
	keywordParameter → #keyword, #word.
	
	pureBody → statements.
	pureBody → returnStatement.
	pureBody → statements, #period, returnStatement.
	
	statements → εExpression.
	statements → εExpression, #period, statements.
	
	returnStatement → #upArrow, expression.
	returnStatement → #upArrow, expression, #period.

	
	εExpression → ε.
	εExpression → expression.
		
	expression → chainOrCascadeExpression.
	expression → #word, #leftArrow, expression.
	

	chainOrCascadeExpression 		→ chainOrCascadeReceiver, chainOrCascadeMessageSends.
	chainOrCascadeExpression 	→ keywordExpression.
	
	chainOrCascadeReceiver → unaryReceiver, unaryMessageSends.
	chainOrCascadeReceiver → unaryExpression, binaryMessageSends.
	chainOrCascadeReceiver → unaryExpression, keywordMessageSends.
	chainOrCascadeReceiver → unaryExpression, binaryMessageSends, keywordMessageSends.

	chainOrCascadeMessageSends → chainOrCascadeMessageSend.
	chainOrCascadeMessageSends → chainOrCascadeMessageSends, chainOrCascadeMessageSend.
	
	chainOrCascadeMessageSend → chainMessageSend.
	chainOrCascadeMessageSend → cascadeMessageSend.

	chainMessageSend → chainDelimiter, unaryMessageSends.
	chainMessageSend → chainDelimiter, unaryMessageSends, binaryMessageSends.
	chainMessageSend → chainDelimiter, unaryMessageSends, binaryMessageSends, keywordMessageSends.
	chainMessageSend → chainDelimiter, unaryMessageSends, keywordMessageSends.
	chainMessageSend → chainDelimiter, binaryMessageSends.
	chainMessageSend → chainDelimiter, binaryMessageSends, keywordMessageSends.
	chainMessageSend → chainDelimiter, keywordMessageSends.
	
	cascadeMessageSend → cascadeDelimiter, keywordMessageSends.
	cascadeMessageSend → cascadeDelimiter, binaryMessageSends.
	cascadeMessageSend → cascadeDelimiter, unaryMessageSends.
	
	cascadeDelimiter → #semicolon.
	chainDelimiter → #colon, #colon.
	
	
	keywordExpression 		→ binaryExpression, keywordMessageSends.
	keywordExpression → binaryExpression. 
	
	binaryExpression 		→ unaryExpression, binaryMessageSends.
	binaryExpression → unaryExpression.
	
	unaryExpression 		→ unaryReceiver, unaryMessageSends.
	unaryExpression → unaryReceiver.
	
	
	keywordMessageSends → keywordMessageSend.
	keywordMessageSends → keywordMessageSends, keywordMessageSend.
	keywordMessageSend → #keyword, binaryExpression.

	
	binaryMessageSends  → binaryMessageSend.
	binaryMessageSends  → binaryMessageSends, binaryMessageSend.
	
	binaryMessageSend → binaryOperator, unaryExpression.
	
	binaryOperator 
		→ #binary;
		→ #verticalBar;
		→ #upArrow.
	
	
	unaryReceiver → terminalExpression.
	unaryReceiver → #backtick, expression, #backtick.
	unaryReceiver → #leftParenthesis, expression, #rightParenthesis.
	unaryReceiver → #leftBracket, body, #rightBracket.
	unaryReceiver → #leftBracket, blockParameters, #verticalBar, body, #rightBracket.
	unaryReceiver → #leftBracket, blockParameters, #rightBracket.
	unaryReceiver → #leftBrace, arrayExpressions, #rightBrace.

	blockParameters → blockParameter.
	blockParameters → blockParameter, blockParameters.
	
	blockParameter → #colon, #word.
		
	arrayExpressions → ε.
	arrayExpressions → expression .
	arrayExpressions → expression, #period, arrayExpressions.

		
	unaryMessageSends → unaryMessageSend.
	unaryMessageSends → unaryMessageSends, unaryMessageSend.
	
	unaryMessageSend → #word.
	
	
	terminalExpression
		→ #character;
		→ #word;
		→ number;
		→ #string;
		→ #literal.
	
	number → #number.
	number → #binary ∈ #(-), #number


More information about the Cuis-dev mailing list