Ad/2010-08-01 Concrete Syntax for a uml action Language for Foundational uml (Alf) Second Revised Submission



Download 1.74 Mb.
Page10/62
Date28.01.2017
Size1.74 Mb.
#9041
1   ...   6   7   8   9   10   11   12   13   ...   62

7.5Names


The name of a named element denotes the element without reference to the namespace of which it is a member (if any). A name may contain any character. However, names that have the form of identifiers may be represented more simply.

The initial character of an identifier must be one of a lowercase letter, an uppercase letter or an underscore. The remaining characters of an identifier are allowed to be any character allowed as an initial character plus any digit. However, a reserved word may not be used as a name, even though it has the form of an identifier (see Subclause 7.6).

An unrestricted name, on the other hand, is represented as a non-empty sequence of characters surrounded by single quotes. The characters within the single quotes may not include non-printable characters (including backspace, tab and newline), However, these characters may be included as part of the name itself through use of an escape sequence. In addition, the single quote character or the backslash character may only be included by using an escape sequence.

An escape sequence is a sequence of two text characters starting with the backslash as an escape character, which actually denotes only a single character (except for the newline escape sequence, which represents however many characters is necessary to represent an end of line in a specific implementation—see Subclause 7.1). Table 7 -3 shows the meaning of the allowed escape sequences.

Table 7 3 Escape Sequences


Escape Sequence

Meaning

\'

Single Quote

\"

Double Quote

\b

Backspace

\f

Form Feed

\t

Tab

\n

Line Terminator

\\

Backslash

It is an error to follow a backslash in an unrestricted name with any other character than allowed in one of the escape sequences above.

Two names are the same if and only if they are composed of the same characters in the same sequence. In particular the case of alphabetic characters is significant (both in identifiers and unrestricted names).

However, an implementation is permitted to consider two names to be conflicting even if they are not the same, but every implementation must observe at least the following rules.


  • Two different identifiers are never conflicting.

  • The corresponding identifier for an unrestricted name is the identifier that results from prepending the name with an underscore and then removing all non-alphanumeric characters from the name other than underscore (_) and dollar sign ($). If the corresponding identifiers for two unrestricted names are different, then the original names do not conflict.

NOTE. The above implementation freedom for name conflicts is intended to make the handling of names simpler for implementations that map Alf text to a target language in which all names must follow the grammar of identifiers. The prepended underscore in a corresponding identifier assures that the result is a legal identifier even if the result would otherwise begin with a number or be empty. Dollar signs are included in corresponding identifiers because they are used in the standard names for equivalent bound elements—see Subclause 6.2.

Examples

customer


nextOrder

'+'


'orders in cart'

'On/Off Switch'



Grammar

Name = Identifier


| UnrestrictedName

Identifier


= IdentifierChars but not a ReservedWord or BooleanLiteral

IdentifierChars


= IdentifierLetter { IdentifierLetterOrDigit }

IdentifierLetterOrDigit


= IdentifierLetter
| Digit

IdentifierLetter


= "a" … "z" | "A" … "Z" | "_"

Digit = "0"


| NonzeroDigit

NonzeroDigit = 1 … "9"

UnrestrictedName
= "'" NameCharacter { NameCharacter } "'"

NameCharacter


= InputCharacter but not "'" or "\\"
| EscapeSequence

EscapeSequence


= "\\" EscapedCharacter

EscapedCharacter


= "'" | "\"" | "b" | "f" | "t" | "n" | "\\"

Cross References

  1. InputCharacter see Subclause 7.1

7.6Reserved Words


A reserved word is a token that has the lexical structure of an identifier but is not allowed to actually be used as an identifier (see Subclause 7.5).

Grammar

ReservedWord


= "abstract" | "accept" | "active" | "activity" | "allInstances" | "any" | "as" | "assoc" | "break" | "case" | "class" | "classify" | "clearAssoc" | "compose" | "createLink" | "datatype" | "default" | "destroyLink" | "do" | "else" | "enum" | "for" | "from" | "hastype" | "if" | "import" | "in" | "inout" | "instanceof" | "let" | "namespace" | "new" | "nonunique" | "null" | "or" | "ordered" | "out" | "package" | "private" | "protected" | "public" | "receive" | "redefines" | "reduce" | "return" | "sequence" | "specializes" | "super" | "signal" | "switch" | "this" | "to" | "while"

7.7Primitive Literals


A primitive literal is used to represent the value of a primitive type. Note that an enumeration literal is not actually denoted as a literal in a lexical sense, but rather by its name as a named element (see also Subclause 8.3.3 on name expressions).

Grammar

PrimitiveLiteral


= BooleanLiteral
| NaturalLiteral
| UnboundedValueLiteral
| StringLiteral

Cross References

  1. BooleanLiteral See Subclause 7.7.1

  2. NaturalLiteral See Subclause 7.7.2

  3. UnboundedValueLiteral See Subclause 7.7.3

  4. StringLiteral See Subclause 7.7.4

7.7.1Boolean Literals


A Boolean literal represents a literal Boolean model element, with the primitive type Boolean. The literal “true” represents an element with the value true, while the literal “false” represents an element with the value false.

Grammar

BooleanLiteral


= "true" | "false"

7.7.2Natural Literals


A natural literal represents a natural number—that is, a non-negative integer. The sets of values of the primitive types Integer and UnlimitedNatural both have the natural numbers as a subset. A natural literal may thus be used to represent values of either of these types.

NOTE. An effective literal for negative values of type Integer can be obtained by applying the unary numeric negation operator (see Subclause 8.5.4) to a natural literal. The unbounded value of type UnlimitedNatural has its own literal (see Subclause 7.7.3).

The Alf standard model library PrimitiveTypes package includes the type Natural that is a specialization of both Integer and UnlimitedNatural (see Subclause 11.2.1), and natural literals are considered to inherently have this type. However, since UML does not provide any literal specification metamodel representation for Natural, any time a natural literal is used, it must be possible to determine from context whether it is an integer or an unlimited natural value that is actually required, so the proper metamodel representation can be chosen when the literal is mapped to fUML. If this cannot be determined implicitly, then an explicit cast (see Subclause 8.5.5) to type Integer or type UnlimitedNatural must be used.

A natural literal may be expressed in decimal (base 10), binary (base 2), octal (base 8) or hexadecimal (base 16). A decimal literal consists of either the single character “0”, representing the integer 0, or a digit from “1” to “9” optionally followed by one or more digits from “0” to “9”, representing a positive integer. A binary literal consists of the prefix “0b” or “0B” followed by one or more of the binary digits “0” or “1”. A hexadecimal literal consists of the prefix “0x” or “0X” followed by one or more hexadecimal digits. Hexadecimal digits with values 10 through 15 are represented by the letters “a” through “f” or “A” through “F”, respectively (case is not significant). An octal literal consists of the digit “0” followed by one or more digits from “0” to “7”. Underscores may be inserted between digits but are ignored in determining the value of the literal.

Subclause 9.1 of the fUML Specification allows a conforming implementation to limit the supported values for Integer and UnlimitedNatural types to a finite set. An Alf implementation may also adopt such a limitation, in which case it may reject any natural literal representing a value outside the supported set.



Examples

1234


0

0b1010111000010000

0B0100_1010_0101_1011

0xAE10


0X4a_5b

057410


0_045_133

Grammar

NaturalLiteral


= DecimalLiteral
| BinaryLiteral
| HexLiteral
| OctalLiteral

DecimalLiteral


= "0"
| NonzeroDigit { [ "_" ] Digit }

BinaryLiteral


= BinaryPrefix BinaryDigit { [ "_" ] BinaryDigit }

BinaryPrefix


= "0" "b"
| "0" "B"

BinaryDigit


= "0" | "1"

HexLiteral


= HexPrefix HexDigit { [ "_" ] HexDigit }

HexPrefix


= "0" "x"
| "0" "X"

HexDigit
= Digit


| "a" … "f"
| "A" … "F"

OctalLiteral


= "0" [ "_" ] OctalDigit { [ "_" ] OctalDigit }

OctalDigit


= "0" … "7"

Cross References

  1. NonzeroDigit see Subclause 7.5

  2. Digit see Subclause 7.5

7.7.3Unbounded Value Literals


An unbounded value literal represents a literal unlimited natural model element for the value unbounded of the primitive type UnlimitedNatural. Other unlimited natural values are represented as natural literals (see Subclause 7.7.2).

Grammar

UnboundedValueLiteral


= "*"

7.7.4String Literals


A string literal represents a literal string model element, with the primitive type String. The string value of the element is given as a sequence of characters, with escape characters resolving to their meaning as given in Subclause 7.5, surrounded by double quote characters (which are not included as part of the string value). The empty string is represented by a pair of double quote characters with no other characters intervening between them.

Example

"This is a string."

"This is a string with a quote character (\") in it."

"This is a string with a new line (\n) in it."



Grammar

StringLiteral = "\"" { StringCharacter } "\""

StringCharacter = InputCharacter but not "\"" or "\\"
| EscapeSequence

Cross References


  1. InputCharacter see Subclause 7.2

  2. EscapeSequence see Subclause 7.5



Download 1.74 Mb.

Share with your friends:
1   ...   6   7   8   9   10   11   12   13   ...   62




The database is protected by copyright ©ininet.org 2024
send message

    Main page