Author Topic: Bare-Bones Oxygen Compiler  (Read 8580 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Bare-Bones Oxygen Compiler
« on: July 25, 2013, 01:55:34 AM »
This requires Oxygen.dll to be in the same folder and inc/RTL32.inc

It reads source code from t.o2bas and compiles to t.exe

You can add code to the start of the source string, followed by a page-feed character (ascii 12). This invisible portion of the source code will then be excluded from line numbering.

  $filename "co2a.exe"
  librarypath "$\"
  includepath "$\inc\"
  include  "RTL32.inc"

  extern lib "oxygen.dll"
  ! o2_mode  (sys m)
  ! o2_basic (string s)
  ! o2_exec  (optional sys p) as sys
  ! o2_error () as string
  ! o2_errno () as sys
  end extern

  o2_mode 9 'ascii=1 bstring=8

  f="t.o2bas"
  cr=chr(13,10)
  s=`includepath "$\inc\"`+cr+
  `%filename "t.exe"`+cr+
  `include "RTL32.inc"`+cr+chr(12)+
  getfile f
  o2_mode 9 'ascii=1 bstring=8
  o2_basic s
  if o2_errno
    print o2_error
  end if
« Last Edit: July 25, 2013, 03:51:33 AM by Charles Pegge »

kryton9

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #1 on: July 26, 2013, 05:06:49 PM »
Quote
This invisible portion of the source code will then be excluded from line numbering.

I am not sure I understand what this is for Charles. I guess I could experiment to figure it out.

Charles Pegge

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #2 on: July 27, 2013, 01:25:51 AM »
Hi Kent,

This is the simplest form of Oxygen compiler. Could be the basis of a customised basic, by adding prefix code, and preprocessor parsing.

Aurel

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #3 on: July 27, 2013, 04:15:43 AM »
Quote
by adding prefix code
Charles
when you say prefix what you mean...

!myPrint {arg,arg}
#myprint

something like this?
or something different ???

Charles Pegge

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #4 on: July 27, 2013, 06:22:11 AM »
I mean equates, directives and include files, preprocessing for customised syntax. Creating a  KrytonBasic possibly :)

kryton9

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #5 on: July 27, 2013, 05:20:51 PM »
It will be fun testing it out. Thanks!

JRS

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #6 on: July 27, 2013, 07:27:06 PM »
Kent,

Maybe it would be fun to convert the MY-BASIC interpreter to work with O2.


John

Aurel

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #7 on: July 27, 2013, 09:38:30 PM »
Quote
Maybe it would be fun to convert the MY-BASIC interpreter to work with O2
Yes John..,this would be very interesting ;)

Peter

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #8 on: July 28, 2013, 07:56:51 AM »
Quote
Maybe it would be fun to convert the MY-BASIC interpreter to work with O2.

Is it a China joke?  :D

Aurel

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #9 on: July 28, 2013, 08:50:40 AM »
Quote
Is it a China joke? 
No is not...
because there is no fortune coockie   ;D

JRS

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #10 on: July 28, 2013, 09:53:58 AM »

kryton9

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #11 on: July 28, 2013, 11:44:12 AM »
Kent,

Maybe it would be fun to convert the MY-BASIC interpreter to work with O2.


John

Nice looking project John. I need a compiled language since I want to work with 3D graphics. But as with anyone who asks me what to learn with, I will add this to my list of recommendations!

JRS

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #12 on: July 28, 2013, 01:15:48 PM »
The idea was to use MY-BASIC as an embedded scripting engine in OxygenBasic as it's host. The embedding and language expansion API for MY-BASIC is really easy to use. If you have any interest in ScriptBasic for embedding, trying MY-BASIC first would make the SB embedding a lot easier on you.


Frankolinox

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #13 on: July 29, 2013, 06:08:33 AM »
how does charles utility for compiling works ;)
1) main code

Code: [Select]
 '
  ' test compiling by oxygen
  '
  $filename "myO2compile.exe"
  librarypath "$\"
  includepath "$\inc\"
  include  "RTL32.inc"

  extern lib "oxygen.dll"
  ! o2_mode  (sys m)
  ! o2_basic (string s)
  ! o2_exec  (optional sys p) as sys
  ! o2_error () as string
  ! o2_errno () as sys
  end extern

  o2_mode 9 'ascii=1 bstring=8

  f="test_compile_o2.o2bas"
  cr=chr(13,10)
  s=`includepath "$\inc\"`+cr+
  `%filename "testO2.exe"`+cr+
  `include "RTL32.inc"`+cr+chr(12)+
  getfile f
  o2_mode 9 'ascii=1 bstring=8
  o2_basic s
  print s
  if o2_errno
    print o2_error
  end if
  print "now you push execute testo2.exe"

2) source code for loading:

Code: [Select]
' test_compile_o2.o2bas

type mydatatype
  string name
  int      n
  single  x,y
end type

mydatatype d[10]={
"thor",2,100,100,
"hulk",2,100,150,
"x-men",4,100,250,
"ironman",3,100,570}

i=3
print d[ i ].name "  " d[ i ].n "  " d[ i ].x "," d[ i ].y

3) "myO2compile.exe" produce a new "testO2.exe" where you can see source code (my idea) and execute it.

for testing see in my zip folder.


best regards, frank

X

kryton9

  • Guest
Re: Bare-Bones Oxygen Compiler
« Reply #14 on: July 29, 2013, 12:39:14 PM »
Frank, I thought this would fix it, but I too can't get it to work. Charles is going to have step in and correct the example you nicely provided.

Code: OxygenBasic
  1. type mydatatype
  2.   string name
  3.   int      n
  4.   single  x,y
  5. end type
  6.  
  7. mydatatype d[10]={
  8. "thor",2,100,100,
  9. "hulk",2,100,150,
  10. "x-men",4,100,250,
  11. "ironman",3,100,570}
  12.  
  13. 'You can add code to the start of the source string, followed by a page-feed character (ascii 12). This invisible portion of the source code will then be excluded from line numbering.
  14. ' I just added this line.
  15. chr(12)
  16.  
  17. i=3
  18. print d[ i ].name "  " d[ i ].n "  " d[ i ].x "," d[ i ].y