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

Types

INTEGER, LONGINT

Syntax

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

Values and Value Lists
intNumberValue :
    intNumberNotation ;

intNumberValueList :
    intNumberValue ( listSeparator intNumberValue )* ;

listSeparator :
    defaultListSeparator | userDefinedListSeparator | newline ;

defaultListSeparator :
    defaultListSeparatorForValuesWithCommas |
    defaultListSeparatorForValuesWithoutCommas ;

defaultListSeparatorForValuesWithCommas :
    ';' whitespace ;

defaultListSeparatorForValuesWithoutCommas :
    ',' whitespace ;

userDefinedListSeparator :
    character whitespace? ;
Arrays and Array Lists
intNumberArray :
     openingArrayDelimiter intNumberValueList closingArrayDelimiter ;

intNumberArrayList :
    intNumberArray ( listSeparator intNumberArray )* ;

openingArrayDelimiter :
    ( defaultOpeningArrayDelimiter | userDefinedOpeningArrayDelimiter ) whitespace ;

closingArrayDelimiter :
    whitespace ( defaultClosingArrayDelimiter | userDefinedOpeningArrayDelimiter ) ;

defaultOpeningArrayDelimiter :
    '{' ;

defaultClosingArrayDelimiter :
    '}' ;

userDefinedOpeningArrayDelimiter :
    '(' | '[' ;

userDefinedClosingArrayDelimiter :
    ')' | ']' ;
Integer Number Notation
intNumberNotation :
    unpaddedIntNumberValue | leftPaddedIntNumberValue | rightPaddedIntNumberValue ;

leftPaddedIntNumberValue :
    whitespace+ unpaddedIntNumberValue ;

rightPaddedIntNumberValue :
    unpaddedIntNumberValue whitespace+ ;

whitespace :
    ' ' ;

unpaddedIntNumberValue :
    simpleFormat | otherFormats ;

simpleFormat :
    negativeSign? decimalDigit+ ;

otherFormats :
    base16CLiteralFmt | base16M2LiteralFmt | decimalFmt ;

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

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

decimalFmt :
    sign? fillChar* integralPart suffix? ;

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

negativeSign :
    '-' ;

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.