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


LANGUAGE DESCRIPTION 7Lexical Structure



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

LANGUAGE DESCRIPTION

7Lexical Structure


Lexically, an Alf input text can be considered to be a sequence of input elements. This clause describes the structure of these input elements. After lexical analysis, the text can then be interpreted as a sequence of tokens that are then parsed according to the Alf syntax, as defined in Clauses 8 through 10.

7.1Line Terminators


The input text can be divided up into lines separated by line terminators. A line terminator may be a single character (such as a line feed) or a sequence of characters (such as a carriage return/line feed combination). This specification does not require any specific encoding for a line terminator, but any encoding used must be consistent throughout any specific input text. Any characters in the input text that are not a part of line terminators are referred to as input characters.

Grammar

LineTerminator


= "\n"

InputCharacter


= any character other than LineTerminator

7.2Input Elements and Tokens


An input element can be white space, a lexical comment or a token. Tokens include documentation comments, names, reserved words, literals, punctuation and operators. After whitespace and lexical comments are removed, the sequence of tokens is interpreted according to the Alf syntax.

Grammar

InputText


= InputElement { InputElement }

InputElement


= WhiteSpace
| LexicalComment
| Token

Token = DocumentationComment


| Name
| ReservedWord
| Literal
| Punctuation
| Operator

Cross References

  1. WhiteSpace see Subclause 7.3

  2. LexicalComment see Subclause 7.4.1

  3. DocumentationComment see Subclause 7.4.2

  4. Name see Subclause 7.5

  5. ReservedWord see Subclause 7.6

  6. Literal see Subclause 7.7

  7. Punctuation see Subclause 7.8

  8. Operator see Subclause 7.9

7.3White Space


A white space character is a space, tab, form feed or line terminator. Any contiguous sequence of white space characters can be used to separate tokens that would otherwise be considered to be part of a single token. It is otherwise ignored.

There are two cases in which the line terminator is not syntactically considered to be white space. A list of annotations for a statement begins with the token “//@” and must end in a line terminator (see Subclause 9.2). And the heading for an in-line statement begins with the token “/*@” and must end in a line terminator (see Subclause 9.3).



Grammar

WhiteSpace


= " " | "\t" | "\f"
| LineTerminator

Cross References

  1. LineTerminator see Subclause 7.1

7.4Comments


Comments are used to annotate other elements of the input text. They have no computable semantics, but simply provide information useful to a human reader of the text. There are three kinds of comments.

  • An end-of-line comment includes all the text from the initial characters “//” to the end of the line, except that “//@” begins a statement annotation rather than a comment (see Subclause 9.2).

  • An in-line comment includes all the text from the initial characters “/*” to the final characters “*/”, except that “/**” begins a documentation comment rather than a lexical comment (see below) and “/*@” begins an inline code block (see Subclause 9.2).

  • A documentation comment includes all the text from the initial characters “/**” to the final characters “*/”. The comment text is the text between the initial characters “/**” and the final characters “*/”.

The first two kinds of comments are together known as lexical comments.

7.4.1Lexical Comments


Lexical comments are not considered tokens. Therefore they are stripped from the input text and not parsed as part of the Alf syntax. The comment symbols and all comment text are ignored. However, a comment cannot occur within a name (see Subclause 7.5) or a string literal (see Subclause 7.7.4).

Examples

// This is an end-of-line comment and will be ignored.

/* This is an in-line comment and will be ignored. */

Grammar

LexicalComment


= EndOfLineComment
| InLineComment

EndOfLineComment


= "//" [ NotAt { InputCharacter } ] LineTerminator

NotAt = InputCharacter but not "@"

InLineComment
= "/*" [ NotStarNotAt CommentText ] "*/"

CommentText


= { NotStar } [ StarCommentText ]

StarCommentText= "*" [ NotStarNotSlash CommentText ]

NotStar
= InputCharacter but not "*"
| LineTerminator

NotStarNotAt


= InputCharacter but not "*" or "@"
| LineTerminator

NotStarNotSlash


= InputCharacter but not "*" or "/"
| LineTerminator

Cross References

  1. InputCharacter see Subclause 7.1

  2. LineTerminator see Subclause 7.1

7.4.2Documentation Comments


Unlike lexical comments, documentation comments are lexically processed as tokens and can therefore be included as syntactic elements. The intent is for documentation comments to be mapped to UML comment elements, containing the comment text, that are actually included as part of the target model. Note that line terminators are allowed within documentation comments.

Examples

/** This is documentation text to be included in the model. */



Grammar

DocumentationComment


= "/**" CommentText "*/"

Cross References

  1. CommentText see Subclause 7.4.1


Download 1.74 Mb.

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




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

    Main page