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 Real Numbers

Types

REAL, LONGREAL, BCD, LONGBCD

Syntax

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

Values and Value Lists
realNumberValue :
    realNumberNotation ;

realNumberValueList :
    realNumberValue ( listSeparator realNumberValue )* ;

listSeparator :
    defaultListSeparator | userDefinedListSeparator | newline ;

defaultListSeparator :
    defaultListSeparatorForValuesWithCommas |
    defaultListSeparatorForValuesWithoutCommas ;

defaultListSeparatorForValuesWithCommas :
    ';' whitespace ;

defaultListSeparatorForValuesWithoutCommas :
    ',' whitespace ;

userDefinedListSeparator :
    character whitespace? ;
Arrays and Array Lists
realNumberArray :
     openingArrayDelimiter realNumberValueList closingArrayDelimiter ;

realNumberArrayList :
    realNumberArray ( listSeparator realNumberArray )* ;

openingArrayDelimiter :
    ( defaultOpeningArrayDelimiter | userDefinedOpeningArrayDelimiter ) whitespace ;

closingArrayDelimiter :
    whitespace ( defaultClosingArrayDelimiter | userDefinedOpeningArrayDelimiter ) ;

defaultOpeningArrayDelimiter :
    '{' ;

defaultClosingArrayDelimiter :
    '}' ;

userDefinedOpeningArrayDelimiter :
    '(' | '[' ;

userDefinedClosingArrayDelimiter :
    ')' | ']' ;
Real Number Notation
realNumberNotation :
    unpaddedRealNumberValue | leftPaddedRealNumberValue | rightPaddedRealNumberValue ;

leftPaddedRealNumberValue :
    whitespace+ unpaddedRealNumberValue ;

rightPaddedRealNumberValue :
    unpaddedRealNumberValue whitespace+ ;

whitespace :
    ' ' ;

unpaddedRealNumberValue :
    simpleFormat | otherFormats ;

simpleFormat :
    negativeSign? decimalDigit decimalPoint decimalDigit+ exponent ;

otherFormats :
    sign? fillChar* ( fixedFmtDecimal | engFmtDecimal | expFmtDecimal ) suffix? ;

fixedFmtDecimal :
    integralPart ( decimalPoint | decimalComma ) fractionalPart ;

engFmtDecimal :
    engIntegralPart ( decimalPoint | decimalComma ) fractionalPart engExponent ;

expFmtDecimal :
    fixedFmtDecimal exponent ;

sign :
    whitespace | '+' | '-' ;

negativeSign :
    '-' ;

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

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

engIntegralPart :
    ( ( ( decimalDigit digitSeparator? )? decimalDigit )? decimalDigit )? decimalDigit ;

fractionalPart :
    ( decimalDigit ( decimalDigit ( decimalDigit digitSeparator )? )? )* decimalDigit ;

exponent :
    'E' ( '+' | '-' ) decimalDigit decimalDigit+ ;

engExponent :
    exponent ;

digitSeparator :
    decimalPointModeDigitSeparator | decimalCommaModeDigitSeparator ;

decimalPointModeDigitSeparator :
    whitespace | ',' ;

decimalCommaModeDigitSeparator :
    whitespace | '.' ;

digitGroup :
    decimalDigit decimalDigit decimalDigit ;

decimalPoint :
    '.' ;

decimalComma :
    ',' ;

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.
  • the numeric value represented by engExponent is always divisible by three.
  • in decimal point mode, decimalPoint is shown instead of decimalComma and decimalPointModeDigitSeparator is shown instead of decimalCommaModeDigitSeparator.
  • in decimal comma mode, decimalComma is shown instead of decimalPoint and decimalCommaModeDigitSeparator is shown instead of decimalPointModeDigitSeparator.