Skip to content

Commit

Permalink
Merge pull request #2704 from henrikt-ma/grammar-whitespace
Browse files Browse the repository at this point in the history
Fix some white-space irregularities in the grammar
  • Loading branch information
HansOlsson committed Nov 6, 2020
2 parents e5ebb00 + 942feba commit fc9d0f8
Showing 1 changed file with 75 additions and 47 deletions.
122 changes: 75 additions & 47 deletions chapters/syntax.tex
Expand Up @@ -21,14 +21,15 @@ \section{Lexical conventions}\label{lexical-conventions}
Q-CHAR = NONDIGIT | DIGIT | "!" | "#" | "$" | "%" | "&" | "(" | ")"
| "*" | "+" | "," | "-" | "." | "/" | ":" | ";" | "<" | ">" | "="
| "?" | "@" | "[" | "]" | "^" | "{" | "}" | "|" | "~" | " " | """
S-ESCAPE = "\'" | "\"" | "\?" | "\\" |
"\a" | "\b" | "\f" | "\n" | "\r" | "\t" | "\v"
S-ESCAPE = "\'" | "\"" | "\?" | "\\"
| "\a" | "\b" | "\f" | "\n" | "\r" | "\t" | "\v"
DIGIT = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
UNSIGNED-INTEGER = DIGIT { DIGIT }
UNSIGNED-REAL = UNSIGNED-INTEGER "." [ UNSIGNED-INTEGER ]
| UNSIGNED_INTEGER [ "." [ UNSIGNED_INTEGER ] ]
( "e" | "E" ) [ "+" | "-" ] UNSIGNED-INTEGER
| "." UNSIGNED-INTEGER [ ( "e" | "E" ) [ "+" | "-" ] UNSIGNED-INTEGER ]
UNSIGNED-REAL =
UNSIGNED-INTEGER "." [ UNSIGNED-INTEGER ]
| UNSIGNED_INTEGER [ "." [ UNSIGNED_INTEGER ] ]
( "e" | "E" ) [ "+" | "-" ] UNSIGNED-INTEGER
| "." UNSIGNED-INTEGER [ ( "e" | "E" ) [ "+" | "-" ] UNSIGNED-INTEGER ]
\end{lstlisting}
\textrm{S-CHAR} is any member of the Unicode character set
(\url{http://www.unicode.org}; see \cref{mapping-package-class-structures-to-a-hierarchical-file-system} for storing as UTF-8 on files) except double-quote `"', and backslash `\textbackslash{}'.
Expand Down Expand Up @@ -76,29 +77,36 @@ \section{Lexical conventions}\label{lexical-conventions}
\section{Grammar}\label{grammar}
\subsection{Stored Definition -- Within}\label{stored-definition-within}
\begin{lstlisting}[language=grammar]
stored-definition:
stored-definition :
[ within [ name ] ";" ]
{ [ final ] class-definition ";" }
\end{lstlisting}

\subsection{Class Definition}\label{class-definition}
\begin{lstlisting}[language=grammar]
class-definition :
[ encapsulated ] class-prefixes
class-specifier
[ encapsulated ] class-prefixes class-specifier

class-prefixes :
[ partial ]
( class | model | [ operator ] record | block | [ expandable ] connector | type |
package | [ pure | impure ] [ operator ] function | operator )
( class
| model
| [ operator ] record
| block
| [ expandable ] connector
| type
| package
| [ pure | impure ] [ operator ] function
| operator
)

class-specifier :
long-class-specifier | short-class-specifier | der-class-specifier

long-class-specifier :
IDENT description-string composition end IDENT
| extends IDENT [ class-modification ] description-string composition
end IDENT
end IDENT

short-class-specifier :
IDENT "=" base-prefix type-specifier [ array-subscripts ]
Expand All @@ -111,16 +119,18 @@ \subsection{Class Definition}\label{class-definition}
base-prefix :
[ input | output ]

enum-list : enumeration-literal { "," enumeration-literal}
enum-list :
enumeration-literal { "," enumeration-literal }

enumeration-literal : IDENT description
enumeration-literal :
IDENT description

composition :
element-list
{ public element-list |
protected element-list |
equation-section |
algorithm-section
{ public element-list
| protected element-list
| equation-section
| algorithm-section
}
[ external [ language-specification ]
[ external-function-call ] [ annotation-clause ] ";" ]
Expand All @@ -137,17 +147,23 @@ \subsection{Class Definition}\label{class-definition}
{ element ";" }

element :
import-clause |
extends-clause |
[ redeclare ]
[ final ]
[ inner ] [ outer ]
( class-definition | component-clause |
replaceable ( class-definition | component-clause )
[ constraining-clause description ] )
import-clause
| extends-clause
| [ redeclare ]
[ final ]
[ inner ] [ outer ]
( class-definition
| component-clause
| replaceable ( class-definition | component-clause )
[ constraining-clause description ]
)

import-clause :
import ( IDENT "=" name | name [ ".*" | "." ( "*" | "{" import-list "}" ) ] ) description
import
( IDENT "=" name
| name [ ".*" | "." ( "*" | "{" import-list "}" ) ]
)
description

import-list :
IDENT { "," IDENT }
Expand All @@ -164,19 +180,21 @@ \subsection{Extends}\label{extends}

\subsection{Component Clause}\label{component-clause}
\begin{lstlisting}[language=grammar]
component-clause:
component-clause :
type-prefix type-specifier [ array-subscripts ] component-list

type-prefix :
[ flow | stream ]
[ discrete | parameter | constant ] [ input | output ]
[ discrete | parameter | constant ]
[ input | output ]

component-list :
component-declaration { "," component-declaration }

component-declaration :
declaration [ condition-attribute ] description

condition-attribute:
condition-attribute :
if expression

declaration :
Expand All @@ -200,7 +218,7 @@ \subsection{Modification}\label{modification}
element-modification-or-replaceable
| element-redeclaration

element-modification-or-replaceable:
element-modification-or-replaceable :
[ each ] [ final ] ( element-modification | element-replaceable )

element-modification :
Expand All @@ -210,7 +228,7 @@ \subsection{Modification}\label{modification}
redeclare [ each ] [ final ]
( short-class-definition | component-clause1 | element-replaceable )

element-replaceable:
element-replaceable :
replaceable ( short-class-definition | component-clause1 )
[ constraining-clause ]

Expand Down Expand Up @@ -238,18 +256,21 @@ \subsection{Equations}\label{equations1}
| for-equation
| connect-clause
| when-equation
| component-reference function-call-args )
| component-reference function-call-args
)
description

statement :
( component-reference ( ":=" expression | function-call-args )
| "(" output-expression-list ")" ":=" component-reference function-call-args
| "(" output-expression-list ")" ":="
component-reference function-call-args
| break
| return
| if-statement
| for-statement
| while-statement
| when-statement )
| when-statement
)
description

if-equation :
Expand Down Expand Up @@ -285,9 +306,9 @@ \subsection{Equations}\label{equations1}
end for

for-indices :
for-index {"," for-index}
for-index { "," for-index }

for-index:
for-index :
IDENT [ in expression ]

while-statement :
Expand All @@ -299,25 +320,29 @@ \subsection{Equations}\label{equations1}
when expression then
{ equation ";" }
{ elsewhen expression then
{ equation ";" } }
{ equation ";" }
}
end when

when-statement :
when expression then
{ statement ";" }
{ elsewhen expression then
{ statement ";" } }
{ statement ";" }
}
end when

connect-clause :
connect "(" component-reference "," component-reference ")"
\end{lstlisting}

\subsection{Expressions}\label{expressions1}
\begin{lstlisting}[language=grammar]
expression :
simple-expression
| if expression then expression { elseif expression then expression }
else expression
| if expression then expression
{ elseif expression then expression }
else expression

simple-expression :
logical-expression [ ":" logical-expression [ ":" logical-expression ] ]
Expand Down Expand Up @@ -364,11 +389,14 @@ \subsection{Expressions}\label{expressions1}
| "{" array-arguments "}"
| end

UNSIGNED-NUMBER : UNSIGNED-INTEGER | UNSIGNED-REAL
UNSIGNED-NUMBER :
UNSIGNED-INTEGER | UNSIGNED-REAL

type-specifier : ["."] name
type-specifier :
["."] name

name : IDENT { "." IDENT }
name :
IDENT { "." IDENT }

component-reference :
[ "." ] IDENT [ array-subscripts ] { "." IDENT [ array-subscripts ] }
Expand All @@ -377,7 +405,7 @@ \subsection{Expressions}\label{expressions1}
"(" [ function-arguments ] ")"

function-arguments :
expression [ "," function-arguments-non-first | for for-indices ]
expression [ "," function-arguments-non-first | for for-indices ]
| function-partial-application [ "," function-arguments-non-first ]
| named-arguments

Expand All @@ -401,7 +429,7 @@ \subsection{Expressions}\label{expressions1}
function-partial-application :
function type-specifier "(" [ named-arguments ] ")"

output-expression-list:
output-expression-list :
[ expression ] { "," [ expression ] }

expression-list :
Expand All @@ -417,7 +445,7 @@ \subsection{Expressions}\label{expressions1}
description-string [ annotation-clause ]

description-string :
[ STRING { "+" STRING } ]
[ STRING { "+" STRING } ]

annotation-clause :
annotation class-modification
Expand Down

0 comments on commit fc9d0f8

Please sign in to comment.