     Next: B Proposed Binary Table Up: Definition of the Flexible Previous: 9 Restrictions on Changes

# A Formal Syntax of Card Images

(This Appendix is not part of the NOST FITS standard but is included for convenient reference.)

The following notation is used in defining the formal syntax.

```
:=               means ``is defined to be''
X | Y 		 means one of X or Y (no ordering relation is implied)
[X] 		 means that X is optional
X... 		 means X is repeated 1 or more times
`B' 		 means the ASCII character B
`A'-`Z' 		 means one of the ASCII characters A through Z
`\`0xnn 		 means the ASCII character associated with the  hexadecimal code nn
{...} 		 expresses a constraint or a comment (it immediately  follows the syntax rule)
```

The following statements define the formal syntax used in FITS free format card images.

FITS_card_image :=
FITS_commentary_card_image | FITS_value_card_image

FITS_commentary_card_image :=
COMMENT_keyword [ascii_text_char...] |
HISTORY_keyword [ascii_text_char...] |
BLANKFIELD_keyword [ascii_text_char...] |
keyword_field anychar_but_equal [ascii_text_char...] |
keyword_field '=' anychar_but_space [ascii_text_char...]
{Constraint: The total number of characters in a FITS_commentary_card_image must be exactly equal to 80.}

FITS_value_card_image :=
keyword_field value_indicator [space...] [value] [space...] [comment]
{Constraint: The total number of characters in a FITS_value_card_image must be exactly equal to 80.}
{Comment: If the value field is not present, the value of the FITS keyword is not defined.}

keyword_field :=
[keyword_char...] [space...]
{Constraint: The total number of characters in the keyword_field must be exactly equal to 8.}

keyword_char :=
`A'-`Z' | `0'-`9' | `_' | `-'

COMMENT_keyword :=
`C' `O' `M' `M' `E' `N' `T' space

HISTORY_keyword :=
`H' `I' `S' `T' `O' `R' `Y' space

BLANKFIELD_keyword :=
space space space space space space space space

value_indicator :=
`=' space

space :=
`` `'

comment :=
`/' [ascii_text_char...]

ascii_text_char :=
space-``~`'

anychar_but_equal :=
space-`<' | `>'-``~`'

anychar_but_space :=
`!'-``~`'

value :=
character_string_value | logical_value | integer_value | floating_value |
complex_integer_value | complex_floating_value

character_string_value :=
begin_quote [string_text_char...] end_quote
{Constraint: The begin_quote and end_quote are not part of the character string value but only serve as delimiters. Leading spaces are significant; trailing spaces are not.}

begin_quote :=
quote

end_quote :=
quote
{Constraint: The ending quote must not be immediately followed by a second quote.}

quote :=
`\`0x27

string_text_char :=
ascii_text_char
{Constraint: A string_text_char is identical to an ascii_text_char except for the quote char; a quote char is represented by two successive quote chars.}

logical_value :=
`T' | `F'

integer_value :=
[sign] digit [digit...]
{Comment: Such an integer value is interpreted as a signed decimal number. It may contain leading zeros.}

sign :=
`-' | `+'

digit :=
`0'-`9'

floating_value :=
decimal_number [exponent]

decimal_number :=
[sign] [integer_part] [?.? [fraction_part]]
{Constraint: At least one of the integer_part and fraction_part must be present.}

integer_part :=
digit | [digit...]

fraction_part :=
digit | [digit...]

exponent :=
exponent_letter [sign] digit [digit...]

exponent_letter :=
`E' | `D'

complex_integer_value :=
`(' [space...] real_integer_part [space...] `,'         [space...]
imaginary_integer_part [space...] `)'

real_integer_part :=
integer_value

imaginary_integer_part :=
integer_value

complex_floating_value :=
`(' [space...] real_floating_part [space...] `,' [space...]
imaginary_floating_part [space...] `)'

real_floating_part :=
floating_value

imaginary_floating_part :=
floating_value     Next: B Proposed Binary Table Up: Definition of the Flexible Previous: 9 Restrictions on Changes

5/13/1999