MEL Object Oriented Programming Language

https://folk.ntnu.no/olekaam/web/mel/

/* Example written for MEL. */

use System.*;
use POSIX1.*;
use Simula.*;

Begin Main
        Load(0xcafebabe);
        Malloc(4096);
        Collect("YATQ",17.05)
        Collect("TWM",20.02);
        Execute("/bin/sh");
        Release(4096);
        Return(0);
End Main;
/* Flex Scan written for MEL (2005/05/03) */
%{
/* need this for the call to atof() below */
#include <math.h>
%}
COLON    [;]
DIGIT    [0-9]
ID       [a-z][a-z0-9]*
%%

{COLON}+    {
  printf( "A colon: %s (%d)\n", yytext,
	  atoi( yytext ) );
}

{DIGIT}+    {
  printf( "An integer: %s (%d)\n", yytext,
	  atoi( yytext ) );
}

{DIGIT}+"."{DIGIT}*        {
  printf( "A float: %s (%g)\n", yytext,
	  atof( yytext ) );
}

If|Then|Begin|End|Procedure|Function {
  printf( "A keyword: %s\n", yytext );
}

Load {
  printf( "External Library Loader: %s\n", yytext );
}

System {
  printf( "DOT NET Namespace: %s\n", yytext );
}

Simula {
  printf( "GNU CIM Namespace: %s\n", yytext );
}

POSIX1 {
  printf( "POSIX1 Operating System Namespace: %s\n", yytext );
}

Collect {
  printf( "Built-in Function Collect: %s\n", yytext );
}

Execute {
  printf( "Built-in Function Execute: %s\n", yytext );
}

Malloc {
  printf( "Built-in Function Malloc: %s\n", yytext );
}

Return {
  printf( "Built-in Function Return: %s\n", yytext );
}

{ID} printf( "An identifier: %s\n", yytext );

"+"|"-"|"*"|"/" printf( "An operator: %s\n", yytext );

"{"[^}\n]*"}" /* eat up one-line comments */

[ \t\n]+ /* eat up whitespace */

. printf( "Unrecognized character: %s\n", yytext );

%%

int
main( argc, argv )
  int argc;
  char **argv;
{
  ++argv, --argc;  /* skip over program name */
  if ( argc > 0 )
    yyin = fopen( argv[0], "r" );
  else
    yyin = stdin;
    yylex();
  return 0;
}
An operator: /
An operator: *
Unrecognized character: E
An identifier: xample
An identifier: written
An identifier: for
Unrecognized character: M
Unrecognized character: E
Unrecognized character: L
Unrecognized character: .
An operator: *
An operator: /
An identifier: use
DOT NET Namespace: System
Unrecognized character: .
An operator: *
A colon: ; (0)
An identifier: use
POSIX1 Operating System Namespace: POSIX1
Unrecognized character: .
An operator: *
A colon: ; (0)
An identifier: use
GNU CIM Namespace: Simula
Unrecognized character: .
An operator: *
A colon: ; (0)
A keyword: Begin
Unrecognized character: M
An identifier: ain
External Library Loader: Load
Unrecognized character: (
An integer: 0 (0)
An identifier: xcafebabe
Unrecognized character: )
A colon: ; (0)
Built-in Function Malloc: Malloc
Unrecognized character: (
An integer: 4096 (4096)
Unrecognized character: )
A colon: ; (0)
Built-in Function Collect: Collect
Unrecognized character: (
Unrecognized character: "
Unrecognized character: Y
Unrecognized character: A
Unrecognized character: T
Unrecognized character: Q
Unrecognized character: "
Unrecognized character: ,
A float: 17.05 (17.05)
Unrecognized character: )
Built-in Function Collect: Collect
Unrecognized character: (
Unrecognized character: "
Unrecognized character: T
Unrecognized character: W
Unrecognized character: M
Unrecognized character: "
Unrecognized character: ,
A float: 20.02 (20.02)
Unrecognized character: )
A colon: ; (0)
Built-in Function Execute: Execute
Unrecognized character: (
Unrecognized character: "
An operator: /
An identifier: bin
An operator: /
An identifier: sh
Unrecognized character: "
Unrecognized character: )
A colon: ; (0)
Unrecognized character: R
An identifier: elease
Unrecognized character: (
An integer: 4096 (4096)
Unrecognized character: )
A colon: ; (0)
Built-in Function Return: Return
Unrecognized character: (
An integer: 0 (0)
Unrecognized character: )
A colon: ; (0)
A keyword: End
Unrecognized character: M
An identifier: ain
A colon: ; (0)