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

WiP.OutputFormatsForNumericTypesRepresentingCardinalNumbers History

Hide minor edits - Show changes to output

2010-01-31 05:14 by benjk -
Deleted lines 89-91:

fixedFmtDecimal :
    integralPart ;
2010-01-31 05:12 by benjk -
Changed lines 10-11 from:
   base16Notation | decimalNotation;
to:
   cardNumberNotation;
Changed line 59 from:
!!!!!Base-16 Notation
to:
!!!!!Cardinal Number Notation
Changed lines 61-73 from:
base16Notation :
    base16CLiteral | base16M2Literal ;

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

base16M2Literal :
    '0' ( decimalDigit | 'A' .. 'F' )+ 'H' ;
@]

!!!!!Decimal Notation
[@
decimalNotation
:
to:
cardNumberNotation :
Changed lines 80-81 from:
   sign? fillChar* ( fixedFmtDecimal | expFmtDecimal ) suffix? ;
to:
   base16CLiteralFmt | base16M2LiteralFmt | decimalFmt ;

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

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

decimalFmt :
    sign? fillChar* integralPart
suffix? ;
Deleted lines 93-95:
expFmtDecimal :
    fixedFmtDecimal exponent ;

Deleted lines 101-109:

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

exponent :
    'E' '+' decimalDigit decimalDigit+ ;

engExponent :
    exponent ;
2010-01-29 16:09 by benjk -
Changed lines 10-11 from:
   cardNumberNotation ;
to:
   base16Notation | decimalNotation;
Changed line 59 from:
!!!!!Cardinal Number Notation
to:
!!!!!Base-16 Notation
Changed lines 61-69 from:
cardNumberNotation :
    unpaddedcardNumberValue | leftPaddedcardNumberValue | rightPaddedcardNumberValue ;

leftPaddedcardNumberValue :
    whitespace+ unpaddedcardNumberValue ;

rightPaddedcardNumberValue :
    unpaddedcardNumberValue whitespace+ ;
to:
base16Notation :
    base16CLiteral | base16M2Literal ;

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

base16M2Literal :
    '0' ( decimalDigit | 'A' .. 'F' )+ 'H' ;
@]

!!!!!Decimal Notation
[@
decimalNotation :
    unpaddedCardNumberValue | leftPaddedCardNumberValue | rightPaddedCardNumberValue ;

leftPaddedCardNumberValue :
    whitespace+ unpaddedCardNumberValue ;

rightPaddedCardNumberValue :
    unpaddedCardNumberValue
whitespace+ ;
Changed line 85 from:
unpaddedcardNumberValue :
to:
unpaddedCardNumberValue :
2010-01-29 15:58 by benjk -
Added lines 1-127:
!!!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 :
    sign? fillChar* ( fixedFmtDecimal | expFmtDecimal ) suffix? ;

fixedFmtDecimal :
    integralPart ;

expFmtDecimal :
    fixedFmtDecimal exponent ;

sign :
    whitespace | '+' ;

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

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

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

exponent :
    'E' '+' decimalDigit decimalDigit+ ;

engExponent :
    exponent ;

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.