Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Output Formats For Numeric Types Representing Cardinal Numbers

Types

CARDINAL, LONGCARD

Syntax

The EBNF for the textual representation of values of types that represent cardinal numbers is

Values and Value Lists
cardNumberValue :
    cardNumberNotation;

cardNumberValueList :
    cardNumberValue ( listSeparator cardNumberValue )* ;

listSeparator :
    defaultListSeparator | userDefinedListSeparator | newline ;

defaultListSeparator :
    defaultListSeparatorForValuesWithCommas |
    defaultListSeparatorForValuesWithoutCommas ;

defaultListSeparatorForValuesWithCommas :
    ';' whitespace ;

defaultListSeparatorForValuesWithoutCommas :
    ',' whitespace ;

userDefinedListSeparator :
    character whitespace? ;
Arrays and Array Lists
cardNumberArray :
     openingArrayDelimiter cardNumberValueList closingArrayDelimiter ;

cardNumberArrayList :
    cardNumberArray ( listSeparator cardNumberArray )* ;

openingArrayDelimiter :
    ( defaultOpeningArrayDelimiter | userDefinedOpeningArrayDelimiter ) whitespace ;

closingArrayDelimiter :
    whitespace ( defaultClosingArrayDelimiter | userDefinedOpeningArrayDelimiter ) ;

defaultOpeningArrayDelimiter :
    '{' ;

defaultClosingArrayDelimiter :
    '}' ;

userDefinedOpeningArrayDelimiter :
    '(' | '[' ;

userDefinedClosingArrayDelimiter :
    ')' | ']' ;
Cardinal Number Notation
cardNumberNotation :
    unpaddedCardNumberValue | leftPaddedCardNumberValue | rightPaddedCardNumberValue ;

leftPaddedCardNumberValue :
    whitespace+ unpaddedCardNumberValue ;

rightPaddedCardNumberValue :
    unpaddedCardNumberValue whitespace+ ;

whitespace :
    ' ' ;

unpaddedCardNumberValue :
    simpleFormat | otherFormats ;

simpleFormat :
    decimalDigit+ ;

otherFormats :
    base16CLiteralFmt | base16M2LiteralFmt | decimalFmt ;

base16CLiteralFmt :
    '0' 'x' ( decimalDigit | 'a' .. 'f' )+ ;

base16M2LiteralFmt :
    '0' ( decimalDigit | 'A' .. 'F' )+ 'H' ;

decimalFmt :
    sign? fillChar* integralPart suffix? ;

sign :
    whitespace | '+' ;

fillChar :
    whitespace | '*' | '0' ;

integralPart :
    decimalDigit decimalDigit? decimalDigit? ( digitSeparator? digitGroup )* ;

digitSeparator :
    whitespace | ',' | '.' ;

digitGroup :
    decimalDigit decimalDigit decimalDigit ;

decimalDigit  :
    '0' .. '9' ;

suffix :
    character* ;

character :
    <any printable ASCII character> ;

newline :
    <runtime host dependent ASCII control sequence for new line> ;

Static Semantics

  • all values in a list are shown in the same notation.
  • all values in a list are shown with identical formatting.