(* Modula-2 R10 Test File for MNV Syntax Colouring *) 

(* --------------------------------------------------
 * THIS FILE IS LICENSED UNDER THE MNV LICENSE
 * see https://github.com/Project-Tick/Project-Tick/blob/master/LICENSE
 * -------------------------------------------------- *)

DEFINITION MODULE Foobar; (*!m2r10*)

IMPORT UNSAFE ALIAS BYTE, WORD, ADDRESS;

CONST MaxFoo = 1.0;

TYPE Foo = ALIAS OF Bar;

(* predefined constants *)
NIL FALSE TRUE

(* predefined types *)
BOOLEAN CHAR UNICHAR OCTET CARDINAL LONGCARD INTEGER LONGINT REAL LONGREAL

(* predefined procedures *)
APPEND INSERT REMOVE SORT SORTNEW

(* predefined functions *)
CHR ORD ODD ABS SGN MIN MAX LOG2 POW2 ENTIER PRED SUCC PTR CAPACITY COUNT LENGTH

(* predefined macros *)
NOP TMIN TMAX TSIZE TLIMIT

(* unsafe builtins *)
UNSAFE

(* unsafe builtin types *)
BYTE WORD LONGWORD ADDRESS OCTETSEQ

(* unsafe builtin procedures *)
ADD SUB DEC INC SETBIT HALT

(* unsafe builtin functions *)
ADR CAST BIT SHL SHR BWNOT BWAND BWOR

(* non-portable language extensions *)
ASSEMBLER ASM REG

(* user defined identifiers *)
foobar Foobar FooBar foo_bar foo0


(* string literals *)
str := "foo 'bar' baz";
str := 'foo "bar" baz';

(* numeric literals *)
0b0110'0011'0110'0000, 0u0A, 0x0123, 0xCAFE'D00D
1'000'000.00, 1.23, 1.23e+10, 1.234'567'890e-1'000


(* language defined pragmas *)
<*MSG=INFO:"foobar"*> <*ENCODING="UTF8"*> <*INLINE*> <*NOINLINE*> <*FFI="C"*>

(* implementation defined pragmas *)
<*GM2.Foobar|W=Bazbam*>


(* single line comment *)
! foo bar baz bam boo 

(* block comments with emphasis *)
(* copyright (c) 2016 Modula-2 Foundation.
   authors B.Kowarsch and R.Sutcliffe
   license see LICENSE *)

(* pre-conditions: foo bar baz bam boo doodle wah.
   post-conditions: foodle babble bozo bim bam dang.
   error-conditions: dada jingle jungle boggle dee boo. *)

(* (* *) *)

(* bindings *)
PROCEDURE [+] sum ( a, b : BCD ) : BCD;

PROCEDURE [MOD] modulus ( n, m : INT64 ) : INT64;

PROCEDURE [RETAIN] Retain ( foo : Foo );

PROCEDURE [LENGTH] length ( str : String ) : LONGCARD;


(* procedures *)
PROCEDURE NewFooWithBar ( VAR foo: Foo; bar : INTEGER );
BEGIN
  NEW(foo);
  foo^.bar := bar;
  RETURN
END NewFooWithBar;

END END;

(* functions *)
PROCEDURE bar ( foo : Foo ) : INTEGER;
BEGIN
  IF foo = NIL THEN
    UNSAFE.HALT
  ELSE
    RETURN foo^.bar
  END (* IF *)
END bar;


(* technical debt *)
TO DO ( 1234, Weight.Major ) (* foo *)
  "redesign foo", 2d;
  "replace foo", 2d;
  "test new foo", 1d
END (* TO DO *);

PROCEDURE SetBaba <*DEPRECATED*> ( n : CARDINAL );

  
(* disabled code *)
?<
WHILE foo = bar DO
  baz(bam, boo)
END (* WHILE *);
>?


(* illegal characters *)
`  ~  $  %  ?  _

(* illegal identifiers *)

_bar  _bar_baz  _bar_baz__bam  _bar_baz__bam_boo

bar_  bar_baz_  bar_baz__bam_  bar_baz__bam_boo_

__bar  __bar_baz  __bar_baz__bam  __bar_baz__bam_boo

bar__  bar_baz__  bar_baz__bam__  bar_baz__bam_boo__

bar__baz  __bar_baz__  __bar__baz__  __


(* module end *)
END Foobar.
