%% File generated by the BNF Converter. \batchmode \documentclass[a4paper,11pt]{article} \usepackage[T1]{fontenc} \usepackage[utf8x]{inputenc} \setlength{\parindent}{0mm} \setlength{\parskip}{1mm} \title{The Language OCL} \author{BNF-converter} \begin{document} \maketitle \newcommand{\emptyP}{\mbox{$\epsilon$}} \newcommand{\terminal}[1]{\mbox{{\texttt {#1}}}} \newcommand{\nonterminal}[1]{\mbox{$\langle \mbox{{\sl #1 }} \! \rangle$}} \newcommand{\arrow}{\mbox{::=}} \newcommand{\delimit}{\mbox{$|$}} \newcommand{\reserved}[1]{\mbox{{\texttt {#1}}}} \newcommand{\literal}[1]{\mbox{{\texttt {#1}}}} \newcommand{\symb}[1]{\mbox{{\texttt {#1}}}} This document was automatically generated by the {\em BNF-Converter}. \section*{The lexical structure of OCL} \subsection*{Literals} Double-precision float literals \nonterminal{Double}\ have the structure indicated by the regular expression $\nonterminal{digit}+ \mbox{{\it `.'}} \nonterminal{digit}+ (\mbox{{\it `e'}} \mbox{{\it `-'}}? \nonterminal{digit}+)?$ i.e.\ two sequences of digits separated by a decimal point, optionally followed by an unsigned or negative exponent. Integer literals \nonterminal{Int}\ are nonempty sequences of digits. String literals \nonterminal{String}\ have the form \terminal{"}$x$\terminal{"}, where $x$ is any sequence of any characters except \terminal{"}\ unless preceded by \verb6\6. Ident literals are recognized by the regular expression \(({\nonterminal{lower}} \mid {\nonterminal{upper}}) ({\nonterminal{upper}} \mid {\nonterminal{lower}} \mid {\nonterminal{digit}} \mid \mbox{`\_'} \mid \mbox{`''})*\) \subsection*{Reserved words and symbols} The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions. The reserved words used in OCL are the following: \\ \begin{tabular}{lll} {\reserved{Bag}} & {\reserved{Collection}} & {\reserved{Sequence}} \\ {\reserved{Set}} & {\reserved{and}} & {\reserved{context}} \\ {\reserved{def}} & {\reserved{else}} & {\reserved{endif}} \\ {\reserved{endpackage}} & {\reserved{false}} & {\reserved{if}} \\ {\reserved{implies}} & {\reserved{in}} & {\reserved{inv}} \\ {\reserved{let}} & {\reserved{not}} & {\reserved{null}} \\ {\reserved{or}} & {\reserved{package}} & {\reserved{post}} \\ {\reserved{pre}} & {\reserved{then}} & {\reserved{true}} \\ {\reserved{xor}} & & \\ \end{tabular} \\ The symbols used in OCL are the following: \\ \begin{tabular}{lll} {\symb{(}} & {\symb{)}} & {\symb{*}} \\ {\symb{{$+$}}} & {\symb{,}} & {\symb{{$-$}}} \\ {\symb{{$-$}{$>$}}} & {\symb{.}} & {\symb{..}} \\ {\symb{/}} & {\symb{:}} & {\symb{::}} \\ {\symb{;}} & {\symb{{$<$}}} & {\symb{{$<$}{$=$}}} \\ {\symb{{$<$}{$>$}}} & {\symb{{$=$}}} & {\symb{{$>$}}} \\ {\symb{{$>$}{$=$}}} & {\symb{?}} & {\symb{@}} \\ {\symb{[}} & {\symb{]}} & {\symb{{\textasciicircum}}} \\ {\symb{\{}} & {\symb{{$|$}}} & {\symb{\}}} \\ \end{tabular} \\ \subsection*{Comments} Single-line comments begin with {\symb{{$-$}{$-$}}}. Multiple-line comments are enclosed with {\symb{/*}} and {\symb{*/}}. \section*{The syntactic structure of OCL} Non-terminals are enclosed between $\langle$ and $\rangle$. The symbols {\arrow} (production), {\delimit} (union) and {\emptyP} (empty rule) belong to the BNF notation. All other symbols are terminals.\\ \begin{tabular}{lll} {\nonterminal{AddOperator}} & {\arrow} &{\terminal{{$+$}}} \\ & {\delimit} &{\terminal{{$-$}}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ClassifierContext}} & {\arrow} &{\nonterminal{Ident}} \\ & {\delimit} &{\nonterminal{Ident}} {\terminal{:}} {\nonterminal{Ident}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{CollectionItem}} & {\arrow} &{\nonterminal{Expression}} \\ & {\delimit} &{\nonterminal{Expression}} {\terminal{..}} {\nonterminal{Expression}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{CollectionKind}} & {\arrow} &{\terminal{Bag}} \\ & {\delimit} &{\terminal{Collection}} \\ & {\delimit} &{\terminal{Sequence}} \\ & {\delimit} &{\terminal{Set}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{CollectionType}} & {\arrow} &{\nonterminal{CollectionKind}} {\terminal{(}} {\nonterminal{SimpleTypeSpecifier}} {\terminal{)}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ConstrBody}} & {\arrow} &{\nonterminal{Stereotype}} {\terminal{:}} {\nonterminal{OCLExpression}} \\ & {\delimit} &{\terminal{def}} {\terminal{:}} {\nonterminal{ListLetExpression}} \\ & {\delimit} &{\terminal{def}} {\nonterminal{Ident}} {\terminal{:}} {\nonterminal{ListLetExpression}} \\ & {\delimit} &{\nonterminal{Stereotype}} {\nonterminal{Ident}} {\terminal{:}} {\nonterminal{OCLExpression}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Constrnt}} & {\arrow} &{\nonterminal{ContextDeclaration}} {\nonterminal{ListConstrBody}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ContextDeclaration}} & {\arrow} &{\terminal{context}} {\nonterminal{ClassifierContext}} \\ & {\delimit} &{\terminal{context}} {\nonterminal{OperationContext}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Declarator}} & {\arrow} &{\nonterminal{DeclaratorVarList}} {\terminal{{$|$}}} \\ & {\delimit} &{\nonterminal{DeclaratorVarList}} {\terminal{;}} {\nonterminal{Ident}} {\terminal{:}} {\nonterminal{TypeSpecifier}} {\terminal{{$=$}}} {\nonterminal{Expression}} {\terminal{{$|$}}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{DeclaratorVarList}} & {\arrow} &{\nonterminal{ListIdent}} \\ & {\delimit} &{\nonterminal{ListIdent}} {\terminal{:}} {\nonterminal{SimpleTypeSpecifier}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{EqualityOperator}} & {\arrow} &{\terminal{{$=$}}} \\ & {\delimit} &{\terminal{{$<$}{$>$}}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Expression}} & {\arrow} &{\nonterminal{Expression}} {\terminal{implies}} {\nonterminal{Expression1}} \\ & {\delimit} &{\nonterminal{Expression1}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{FormalParameter}} & {\arrow} &{\nonterminal{Ident}} {\terminal{:}} {\nonterminal{TypeSpecifier}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{IfExpression}} & {\arrow} &{\terminal{if}} {\nonterminal{Expression}} {\terminal{then}} {\nonterminal{Expression}} {\terminal{else}} {\nonterminal{Expression}} {\terminal{endif}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{LetExpression}} & {\arrow} &{\terminal{let}} {\nonterminal{Ident}} {\terminal{(}} {\nonterminal{ListFormalParameter}} {\terminal{)}} {\terminal{{$=$}}} {\nonterminal{Expression}} \\ & {\delimit} &{\terminal{let}} {\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Expression}} \\ & {\delimit} &{\terminal{let}} {\nonterminal{Ident}} {\terminal{:}} {\nonterminal{TypeSpecifier}} {\terminal{{$=$}}} {\nonterminal{Expression}} \\ & {\delimit} &{\terminal{let}} {\nonterminal{Ident}} {\terminal{(}} {\nonterminal{ListFormalParameter}} {\terminal{)}} {\terminal{:}} {\nonterminal{TypeSpecifier}} {\terminal{{$=$}}} {\nonterminal{Expression}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{LiteralCollection}} & {\arrow} &{\nonterminal{CollectionKind}} {\terminal{\{}} {\nonterminal{ListCollectionItem}} {\terminal{\}}} \\ & {\delimit} &{\nonterminal{CollectionKind}} {\terminal{\{}} {\terminal{\}}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{LogicalOperator}} & {\arrow} &{\terminal{and}} \\ & {\delimit} &{\terminal{or}} \\ & {\delimit} &{\terminal{xor}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{MessageArg}} & {\arrow} &{\nonterminal{Expression}} \\ & {\delimit} &{\terminal{?}} \\ & {\delimit} &{\terminal{?}} {\terminal{:}} {\nonterminal{TypeSpecifier}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{MultiplyOperator}} & {\arrow} &{\terminal{/}} \\ & {\delimit} &{\terminal{*}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{OCLExpression}} & {\arrow} &{\nonterminal{Expression}} \\ & {\delimit} &{\nonterminal{ListLetExpression}} {\terminal{in}} {\nonterminal{Expression}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{OCLExpressions}} & {\arrow} &{\nonterminal{ListConstrnt}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{OCLLiteral}} & {\arrow} &{\terminal{false}} \\ & {\delimit} &{\terminal{true}} \\ & {\delimit} &{\nonterminal{OCLNumber}} \\ & {\delimit} &{\nonterminal{String}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{OCLNumber}} & {\arrow} &{\nonterminal{Double}} \\ & {\delimit} &{\nonterminal{Integer}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{OCLPackage}} & {\arrow} &{\terminal{package}} {\nonterminal{PackageName}} {\nonterminal{OCLExpressions}} {\terminal{endpackage}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{OCLfile}} & {\arrow} &{\nonterminal{ListOCLPackage}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{OperationContext}} & {\arrow} &{\nonterminal{Ident}} {\terminal{::}} {\nonterminal{OperationName}} {\terminal{(}} {\nonterminal{ListFormalParameter}} {\terminal{)}} \\ & {\delimit} &{\nonterminal{Ident}} {\terminal{::}} {\nonterminal{OperationName}} {\terminal{(}} {\nonterminal{ListFormalParameter}} {\terminal{)}} {\terminal{:}} {\nonterminal{ReturnType}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{OperationName}} & {\arrow} &{\terminal{{$+$}}} \\ & {\delimit} &{\terminal{and}} \\ & {\delimit} &{\terminal{/}} \\ & {\delimit} &{\terminal{{$=$}}} \\ & {\delimit} &{\terminal{{$>$}}} \\ & {\delimit} &{\terminal{{$>$}{$=$}}} \\ & {\delimit} &{\terminal{implies}} \\ & {\delimit} &{\terminal{{$<$}}} \\ & {\delimit} &{\terminal{{$<$}{$=$}}} \\ & {\delimit} &{\terminal{*}} \\ & {\delimit} &{\terminal{{$<$}{$>$}}} \\ & {\delimit} &{\terminal{not}} \\ & {\delimit} &{\nonterminal{Ident}} \\ & {\delimit} &{\terminal{or}} \\ & {\delimit} &{\terminal{{$-$}}} \\ & {\delimit} &{\terminal{xor}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{PCPHelper}} & {\arrow} &{\terminal{{$|$}}} {\nonterminal{Expression}} \\ & {\delimit} &{\terminal{:}} {\nonterminal{SimpleTypeSpecifier}} \\ & {\delimit} &{\terminal{,}} {\nonterminal{Expression}} \\ & {\delimit} &{\terminal{;}} {\nonterminal{Ident}} {\terminal{:}} {\nonterminal{TypeSpecifier}} {\terminal{{$=$}}} {\nonterminal{Expression}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{PName}} & {\arrow} &{\nonterminal{Ident}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{PackageName}} & {\arrow} &{\nonterminal{PathName}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{PathName}} & {\arrow} &{\nonterminal{ListPName}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{PossPropCallParam}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{PropertyCallParameters}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{PossQualifiers}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{Qualifiers}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{PossTimeExpression}} & {\arrow} &{\terminal{@}} {\terminal{pre}} \\ & {\delimit} &{\emptyP} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{PostfixOperator}} & {\arrow} &{\terminal{{$-$}{$>$}}} \\ & {\delimit} &{\terminal{.}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{PropertyCall}} & {\arrow} &{\nonterminal{PathName}} {\nonterminal{PossTimeExpression}} {\nonterminal{PossQualifiers}} {\nonterminal{PossPropCallParam}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{PropertyCallParameters}} & {\arrow} &{\terminal{(}} {\nonterminal{ListExpression}} {\terminal{)}} \\ & {\delimit} &{\terminal{(}} {\nonterminal{Expression}} {\nonterminal{ListPCPHelper}} {\terminal{)}} \\ & {\delimit} &{\terminal{(}} {\nonterminal{Declarator}} {\nonterminal{ListExpression}} {\terminal{)}} \\ & {\delimit} &{\terminal{(}} {\terminal{)}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Qualifiers}} & {\arrow} &{\terminal{[}} {\nonterminal{ListExpression}} {\terminal{]}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{RelationalOperator}} & {\arrow} &{\terminal{{$>$}}} \\ & {\delimit} &{\terminal{{$>$}{$=$}}} \\ & {\delimit} &{\terminal{{$<$}}} \\ & {\delimit} &{\terminal{{$<$}{$=$}}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ReturnType}} & {\arrow} &{\nonterminal{TypeSpecifier}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{SimpleTypeSpecifier}} & {\arrow} &{\nonterminal{PathName}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Stereotype}} & {\arrow} &{\terminal{inv}} \\ & {\delimit} &{\terminal{post}} \\ & {\delimit} &{\terminal{pre}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{TypeSpecifier}} & {\arrow} &{\nonterminal{CollectionType}} \\ & {\delimit} &{\nonterminal{SimpleTypeSpecifier}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{UnaryOperator}} & {\arrow} &{\terminal{{$-$}}} \\ & {\delimit} &{\terminal{not}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListIdent}} & {\arrow} &{\nonterminal{Ident}} \\ & {\delimit} &{\nonterminal{Ident}} {\terminal{,}} {\nonterminal{ListIdent}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListCollectionItem}} & {\arrow} &{\nonterminal{CollectionItem}} \\ & {\delimit} &{\nonterminal{CollectionItem}} {\terminal{,}} {\nonterminal{ListCollectionItem}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListConstrBody}} & {\arrow} &{\nonterminal{ConstrBody}} \\ & {\delimit} &{\nonterminal{ConstrBody}} {\nonterminal{ListConstrBody}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListConstrnt}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{Constrnt}} {\nonterminal{ListConstrnt}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListExpression}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{Expression}} \\ & {\delimit} &{\nonterminal{Expression}} {\terminal{,}} {\nonterminal{ListExpression}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListFormalParameter}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{FormalParameter}} \\ & {\delimit} &{\nonterminal{FormalParameter}} {\terminal{,}} {\nonterminal{ListFormalParameter}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListLetExpression}} & {\arrow} &{\nonterminal{LetExpression}} \\ & {\delimit} &{\nonterminal{LetExpression}} {\nonterminal{ListLetExpression}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListMessageArg}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{MessageArg}} \\ & {\delimit} &{\nonterminal{MessageArg}} {\terminal{,}} {\nonterminal{ListMessageArg}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListOCLPackage}} & {\arrow} &{\nonterminal{OCLPackage}} \\ & {\delimit} &{\nonterminal{OCLPackage}} {\nonterminal{ListOCLPackage}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListPCPHelper}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{PCPHelper}} {\nonterminal{ListPCPHelper}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListPName}} & {\arrow} &{\nonterminal{PName}} \\ & {\delimit} &{\nonterminal{PName}} {\terminal{::}} {\nonterminal{ListPName}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Expression1}} & {\arrow} &{\nonterminal{Expression1}} {\nonterminal{LogicalOperator}} {\nonterminal{Expression2}} \\ & {\delimit} &{\nonterminal{Expression2}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Expression2}} & {\arrow} &{\nonterminal{Expression2}} {\nonterminal{EqualityOperator}} {\nonterminal{Expression3}} \\ & {\delimit} &{\nonterminal{Expression3}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Expression3}} & {\arrow} &{\nonterminal{Expression3}} {\nonterminal{RelationalOperator}} {\nonterminal{Expression4}} \\ & {\delimit} &{\nonterminal{Expression4}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Expression4}} & {\arrow} &{\nonterminal{Expression4}} {\nonterminal{AddOperator}} {\nonterminal{Expression5}} \\ & {\delimit} &{\nonterminal{Expression5}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Expression5}} & {\arrow} &{\nonterminal{Expression5}} {\nonterminal{MultiplyOperator}} {\nonterminal{Expression6}} \\ & {\delimit} &{\nonterminal{Expression6}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Expression6}} & {\arrow} &{\nonterminal{UnaryOperator}} {\nonterminal{Expression7}} \\ & {\delimit} &{\nonterminal{Expression7}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Expression7}} & {\arrow} &{\nonterminal{Expression7}} {\nonterminal{PostfixOperator}} {\nonterminal{PropertyCall}} \\ & {\delimit} &{\nonterminal{Expression7}} {\terminal{{\textasciicircum}}} {\nonterminal{PathName}} {\terminal{(}} {\nonterminal{ListMessageArg}} {\terminal{)}} \\ & {\delimit} &{\nonterminal{Expression8}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Expression8}} & {\arrow} &{\nonterminal{IfExpression}} \\ & {\delimit} &{\nonterminal{PropertyCall}} \\ & {\delimit} &{\nonterminal{OCLLiteral}} \\ & {\delimit} &{\nonterminal{LiteralCollection}} \\ & {\delimit} &{\terminal{null}} \\ & {\delimit} &{\terminal{(}} {\nonterminal{Expression}} {\terminal{)}} \\ \end{tabular} \\ \end{document}