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

Pragmas

<< Ignore Symbols

#1 Pragma   syntax diagram
pragma :=
  '<*' pragmaBody '*>'
  ;

#1.1 Pragma Body   syntax diagram
pragmaBody :=
  ctMsgPragma | condCompPragma | procDeclAttrPragma | promiseToWritePragma |
  forwardDeclPragma | charEncodingPragma | memAlignmentPragma |
  bitPaddingPragma | purityAttrPragma | varDeclAttrPragma | deprecationPragma |
  genTimestampPragma | memMappingPragma | ffiPragma | ffidentPragma |
  implDefinedPragma
  ;

#2 Body Of Compile Time Message Pragma   syntax diagram
ctMsgPragma :=
  MSG '=' ctMsgMode ':' ctMsgComponentList
  ;

#2.1 Message Mode   syntax diagram
ctMsgMode :=
  INFO | WARN | ERROR | FATAL
  ;

#2.2 Message Component List   syntax diagram
ctMsgComponentList :=
  ctMsgComponent ( ',' ctMsgComponent )*
  ;

#2.3 Message Component   syntax diagram
ctMsgComponent :=
  StringLiteral | constQualident | '?' valuePragma
  ;
#2.4 Constant Qualified Identifier   syntax diagram
constQualident := qualident ;

#2.5 Value Pragma   syntax diagram
valuePragma :=
  ALIGN | ENCODING | valuePragmaSymbol
  ; 

#2.6 Value Pragma Symbol   syntax diagram
valuePragmaSymbol := PragmaSymbol ;

#2.7 Pragma Symbol   syntax diagram
PragmaSymbol :=
  Letter+
  ;

#3 Body Of Conditional Compilation Pragma   syntax diagram
condCompPragma :=
  ( IF | ELSIF ) inPragmaExpression | ELSE | END
  ;

#4 Body Of Procedure Declaration Attribute Pragma   syntax diagram
procDeclAttrPragma :=
  INLINE | NOINLINE | BLOCKING | NORETURN
  ;

#5 Body Of Promise-To-Write Pragma   syntax diagram
promiseToWritePragma :=
  OUT
  ;

#6 Body Of Forward Declaration Pragma   syntax diagram
forwardDeclPragma :=
  FORWARD ( TYPE identList | procedureHeader )
  ;

#7 Body Of Character Encoding Pragma   syntax diagram
charEncodingPragma :=
  ENCODING '=' StringLiteral /* "ASCII" or "UTF8" */
  ( ':' codePointSampleList )?
  ;

#7.1a Code Point Sample List   syntax diagram
codePointSampleList :=
  codePointSample ( ',' codePointSample )*
  ;
#7.1b Code Point Sample
codePointSample :=
  quotedCharacter '=' charCodeLiteral
  ;

#7.2 Quoted Character   syntax diagram
quotedCharacter := StringLiteral ; /* single character only */

#7.3 Character Code Literal   syntax diagram
charCodeLiteral := NumberLiteral ; /* whole number only */

#8 Body Of Memory Alignment Pragma   syntax diagram
memAlignmentPragma :=
  ALIGN '=' inPragmaExpr
  ;

#9 Body Of Bit Padding Pragma   syntax diagram
bitPaddingPragma :=
  PADBITS '=' inPragmaExpr
  ;

#10 Body Of Purity Attribute Pragma   syntax diagram
purityAttrPragma :=
  PURITY '=' inPragmaExpr /* values 0 .. 3 */
  ;

#11 Body Of Variable Declaration Attribute Pragma   syntax diagram
varDeclAttrPragma :=
  SINGLEASSIGN | LOWLATENCY | VOLATILE
  ;

#12 Body Of Deprecation Pragma   syntax diagram
deprecationPragma :=
  DEPRECATED
  ;

#13 Body Of Library Generation Timestamp Pragma   syntax diagram
genTimestampPragma :=
  GENERATED template ',' datestamp ',' timestamp
  ;

#13.1 Datestamp   syntax diagram
datestamp :=
  year '-' month '-' day
  ;

#13.2 Timestamp   syntax diagram
timestamp :=
  hours ':' minutes ':' seconds utcOffset?
  ;

#13.3 Year, Month, Day, Hours, Minutes, Seconds   syntax diagram
year := wholeNumber ;

month := wholeNumber ;

day := wholeNumber ;

hours := wholeNumber ;

minutes := wholeNumber ;

seconds := wholeNumber ;

#13.4 UTC Offset   syntax diagram
utcOffset :=
  ( '+' | '-' ) wholeNumber
  ;

#14 Body Of Memory Mapping Pragma   syntax diagram
memMappingPragma :=
  ADDR '=' inPragmaExpr
  ;

#15 Body Of Foreign Function Interface Pragma   syntax diagram
ffiPragma :=
  FFI '=' StringLiteral /* "C", "Fortran", "CLR" or "JVM" */
  ;

#16 Body Of Foreign Function Identifier Mapping Pragma   syntax diagram
ffidentPragma :=
  FFIDENT '=' StringLiteral /* foreign library identifier */
  ;

#17 Body Of Implementation Defined Pragma   syntax diagram
implDefinedPragma :=
  ( implPrefix '.' )? PragmaSymbol ( '=' inPragmaExpr )? '|' ctMsgMode
  ;

#17.1 Implementation Prefix   syntax diagram
implPrefix :=
  Letter LetterOrDigit+
  ;

#18 In-Pragma Expression   syntax diagram
inPragmaExpr :=
  inPragmaSimpleExpr ( inPragmaOperL1 inPragmaSimpleExpr )?
  ;

#18.1 In-Pragma Level-1 Operator   syntax diagram
inPragmaOperL1 :=
  '=' | '#' | '<' | '<=' | '>' | '>='
  ;

#19 In-Pragma Simple Expression   syntax diagram
inPragmaSimpleExpr :=
  inPragmaTerm ( inPragmaOperL2 inPragmaTerm )* | '-' inPragmaFactor
  ;

#19.1 In-Pragma Level-2 Operator   syntax diagram
inPragmaOperL2 :=
  '+' | '-' | OR
  ;

#20 In-Pragma Term   syntax diagram
inPragmaTerm :=
  inPragmaSimpleTerm ( inPragmaOperL3 inPragmaSimpleTerm )*
  ;

#20.1 In-Pragma Level-3 Operator   syntax diagram
inPragmaOperL3 :=
  '*' | DIV | MOD | AND
  ;

#21 In-Pragma Simple Term   syntax diagram
inPragmaSimpleTerm :=
  NOT? inPragmaFactor
  ;

#22 In-Pragma Factor   syntax diagram
inPragmaFactor :=
  WholeNumber |
  /* constQualident is covered by inPragmaCtFunctionCall */
  '(' inPragmaExpr ')' | inPragmaCtFunctionCall
  ;

#23 In-Pragma Compile Time Function Call   syntax diagram
inPragmaCtFunctionCall :=
  qualident ( '(' inPragmaExpr ( ',' inPragmaExpr )* ')' )?
  ;