Grammar of Class Diagrams

Below, we give the grammar for class diagrams. The grammar contains only information that we need for our algorithms. For instance, the different relationships between classes are not captured.

ClassD = ( class)+

Class =

className {attribute} {operation}.

attribute =

attributeName " ("

("string =" string_litteral )

| ( "integer =" integer_litteral )

| ( "float =" floating_point_litteral )

| ( "char =" character_litteral )

| ( "boolean =" "true" | "false" )

")".

operation =

operationName " (" [ parameter

{"," parameter } ] ")" [ ":"

("string" | "integer | "float"

| "char" | "boolean" ) ]

"pre" orExpression

"post" ( orExpression | ifExpression ).

parameter =

parameterName ":" ( "string" | "integer

| "float" | "char" | "boolean" ).

ifExpression =

"(IF" orExpression "THEN" orExpression "ENDIF)".

orExpression =

andExpression | ( "(" andExpression ("or" andExpression )+ ")").

andExpression =

basicExpression | ( "(" basicExpression ("and" basicExpression ")")+ ).

basicExpression =

"(" identifier ( ( ( "=" | "<" | ">" "<=" | ">=" ) ( string_literal | character_literal | interger_literal | floating_point_literal ) )

| ("=" ( "true" | "false" ) ).

className, attributeName, operationName, parameterName: identifier.

 

A ClassD consists of a set of classes. A class is described by his name, a set of attributes and a set of operations.