This appendix lists the grammar rules of the Metaslang specification language. These rules are identical to those of the Chapter on Metaslang. They are brought together here, without additional text, for easy reference.
The grammar description formalism.
wiffle ::= waffle [ waffle-tail ] | piffle { + piffle }* |
piffle ::= 1 | M { piffle }* |
Symbols and Names.
symbol ::= name | literal | special-symbol name ::= word-symbol | non-word-symbol word-symbol ::= word-start-mark { word-continue-mark }* word-start-mark ::= letter word-continue-mark ::= letter | decimal-digit | _ | ? letter ::= A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z decimal-digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 non-word-symbol ::= non-word-mark { non-word-mark }* non-word-mark ::= ` | ~ | ! | @ | $ | ^ | & | * | - | = | + | \ | | | : | < | > | / | ? special-symbol ::= _ | ( | ) | [ | ] | { | } | ; | , | . |
Comments.
comment ::= line-end-comment | block-comment line-end-comment ::= % line-end-comment-body line-end-comment-body ::= any-text-up-to-end-of-line block-comment ::= (* block-comment-body *) block-comment-body ::= any-text-including-newlines-and-nested-block-comments |
Units.
unit-definition ::= unit-identifier = unit-term unit-term ::= spec-term | morphism-term | diagram-term | target-code-term | proof-term specware-file-contents ::= unit-term | infile-unit-definition { infile-unit-definition }* infile-unit-definition ::= fragment-identifier = unit-term |
Unit Identifiers.
unit-identifier ::= swpath-based-path | relative-path swpath-based-path ::= / relative-path relative-path ::= { path-element / }* path-element [ # path-element ] path-element ::= word-symbol |
Specs.
spec-term ::= unit-identifier | spec-form | spec-qualification | spec-translation | spec-substitution | diagram-colimit | obligator |
Spec Forms.
spec-form ::= spec { declaration }* endspec |
Qualifications.
spec-qualification ::= qualifier qualifying spec-term qualifier ::= word-symbol qualifiable-name ::= unqualified-name | qualified-name unqualified-name ::= name qualified-name ::= qualifier . name |
Translations.
spec-translation ::= translate spec-term by name-map name-map ::= { [ name-map-item { , name-map-item }* ] } name-map-item ::= sort-name-map-item | op-name-map-item sort-name-map-item ::= [ sort ] qualifiable-name +-> qualifiable-name op-name-map-item ::= [ op ] annotable-qualifiable-name +-> annotable-qualifiable-name annotable-qualifiable-name ::= qualifiable-name [ : sort ] |
Substitutions.
spec-substitution ::= spec-term [ morphism-term ] |
Diagram Colimits.
diagram-colimit ::= colimit diagram-term |
Morphisms.
morphism-term ::= unit-identifier | spec-morphism spec-morphism ::= morphism spec-term -> spec-term name-map |
Diagrams.
diagram-term ::= unit-identifier | diagram-form diagram-form ::= diagram { diagram-element { , diagram-element }* } diagram-element ::= diagram-node | diagram-edge diagram-node ::= name +-> spec-term diagram-edge ::= name : name -> name +-> morphism-term |
Generate Terms.
target-code-term ::= generate target-language-name spec-term [ in string-literal ] target-language-name ::= lisp |
Proof Terms.
proof-term ::= prove claim-name in spec-term [ with prover-name ] [ using { claim-list } ] [ options prover-options ] prover-name ::= snark claim-list ::= claim-name { , claim-name }* prover-options ::= string-literal |
Declarations.
declaration ::= import-declaration | sort-declaration | op-declaration | definition definition ::= sort-definition | op-definition | claim-definition equals ::= is | = |
Import-declarations.
import-declaration ::= import spec-term |
Sort-declarations.
Sort-definitions.
sort-definition ::= sort sort-name [ formal-sort-parameters ] equals sort |
Op-declarations.
op-declaration ::= op op-name [ fixity ] : sort-scheme fixity ::= associativity priority associativity ::= infixl | infixr priority ::= nat-literal sort-scheme ::= [ sort-variable-binder ] sort sort-variable-binder ::= fa ( local-sort-variable-list ) |
Op-definitions.
Claim-definitions.
claim-definition ::= claim-kind claim-name equals claim claim-kind ::= axiom | theorem | conjecture claim-name ::= name claim ::= [ sort-quantification ] expression sort-quantification ::= sort sort-variable-binder |
Sorts.
Sort-sums.
sort-sum ::= sort-summand { sort-summand }* sort-summand ::= | constructor [ slack-sort ] constructor ::= name |
Sort-arrows.
sort-arrow ::= arrow-source -> sort arrow-source ::= sort-sum | slack-sort |
Sort-products.
sort-product ::= tight-sort * tight-sort { * tight-sort }* |
Sort-instantiations.
sort-instantiation ::= sort-name actual-sort-parameters actual-sort-parameters ::= closed-sort | ( proper-sort-list ) proper-sort-list ::= sort , sort { , sort }* |
Sort-names.
sort-name ::= qualifiable-name |
Sort-records.
sort-record ::= { [ field-sorter-list ] } | ( ) field-sorter-list ::= field-sorter { , field-sorter }* field-sorter ::= field-name : sort field-name ::= name |
Sort-restrictions.
sort-restriction ::= ( slack-sort | expression ) |
Sort-comprehensions.
sort-comprehension ::= { annotated-pattern | expression } |
Sort-quotients.
sort-quotient ::= closed-sort / closed-expression |
Expressions.
Lambda-forms.
lambda-form ::= fn match |
Case-expressions.
case-expression ::= case expression of match |
Let-expressions.
If-expressions.
if-expression ::= if expression then expression else expression |
Quantifications.
Applications.
Annotated-expressions.
annotated-expression ::= tight-expression : sort |
Op-names.
op-name ::= qualifiable-name |
Literals.
literal ::= boolean-literal | nat-literal | char-literal | string-literal |
Boolean-literals.
boolean-literal ::= true | false |
Nat-literals.
nat-literal ::= decimal-digit { decimal-digit }* |
Char-literals.
char-literal ::= #char-literal-glyph char-literal-glyph ::= char-glyph | " char-glyph ::= letter | decimal-digit | other-char-glyph other-char-glyph ::= ! | : | @ | # | $ | % | ^ | & | * | ( | ) | _ | - | + | = | | | ~ | ` | . | , | < | > | ? | / | ; | ' | [ | ] | { | } | \\ | \" | \a | \b | \t | \n | \v | \f | \r | \s | \x hexadecimal-digit hexadecimal-digit hexadecimal-digit ::= decimal-digit | a | b | c | d | e | f | A | B | C | D | E | F |
String-literals.
string-literal ::= " string-body " string-body ::= { string-literal-glyph }* string-literal-glyph ::= char-glyph | significant-whitespace significant-whitespace ::= space | tab | newline |
Field-selections.
field-selection ::= closed-expression . field-selector field-selector ::= nat-literal | field-name |
Tuple-displays.
tuple-display ::= ( tuple-display-body ) tuple-display-body ::= [ expression , expression { , expression }* ] |
Record-displays.
record-display ::= { record-display-body } record-display-body ::= [ field-filler { , field-filler }* ] field-filler ::= field-name equals expression |
Sequential-expressions.
List-displays.
list-display ::= [ list-display-body ] list-display-body ::= [ expression { , expression }* ] |
Structors.
structor ::= projector | relaxator | restrictor | quotienter | chooser | embedder | embedding-test |
projector ::= project field-selector |
relaxator ::= relax closed-expression |
restrictor ::= restrict closed-expression |
quotienter ::= quotient closed-expression |
chooser ::= choose closed-expression |
embedder ::= [ embed ] constructor |
embedding-test ::= embed? constructor |
Patterns.