IT-Berater: Theo Gottwald (IT-Consultant) > Brians Board

PluriBASIC - Progress March 7 2018

<< < (2/8) > >>

Charles Pegge:

I would warmly welcome any compiler development that needs a back-end. Oxygen.dll (141kb) provides all-in-one basic compiling, assembly and linkage, both for PE files and direct JIT execution. The benefit to the Oxygen party would be to establish the best protocols and techniques for creating new compilers :)

The core functions are the minimum required for BASIC, and uses ole strings, like PowerBasic and thinBasic.

It is quite easy to add extensions and specialised syntax such as DDT, which can be decomposed into standard procedures.

As an example, here is our current co2 compiler source (4k), using oxygen.dll.


--- Code: ---
 'Compiler for OxygenBasic
 '========================

 'Charles Pegge
 '12:53 11/06/2015
 '10:17 06/03/2017
 '15:26 13/01/2018

  #compact
  #file "co2.exe" 'Oxygen dependent compiling
  %NoConsole
  uses SysUtil
  uses console

  extern lib "oxygen.dll"
  uses oxygenAPI
  end extern

  BufferObject pr

  sys    a,i
  string s,t,u
  sys    swa,swc,swm          'COMPILER SWITCHES
  string fname,mname,xname    '1st FILE NAME COMPONENTS
  string bfname,bmname,bxname '2nd FILE NAME COMPONENTS
  string er                   'ERROR MESSAGES
  '
  s=lcase CommandLineArgs()
  if not s then goto nofile
  '
  'SWITCHES
  '========
  i=0
  do
    i++ : skiplspace s,i
    if ascb<>45 then exit do
    i++ : skiplspace s,i
    select ascb
    case "i" : swa=ascb '-i intermediate output
    case "a" : swa=ascb '-a asm output
    case "b" : swa=ascb '-b o2 output
    case "c" : swc=ascb '-c compile
    case "m" : swm=ascb '-m do not show messagebox
    end select
  end do
  '
  s=mid s,i
  '
  nofile: 'check
  '=============
  '
  if not s then
  pr.in "
  compiler options:
  <filename>       compile and execute directly in memory
  -a <filename>    list assembly code
  -b <filename>    list o2 machine script
  -c <filename>    <optional filename>  compile to a binary
  -i <filename>    list intermediate code
  -m               output to console
  "
  jmp fwd done
  end if
  '
  'GET FILENAMES
  '=============
  '
  i=1 : xname=".o2bas" 'DEFAULT SOURCE EXTENSION NAME
  fname=ParseFileName(s,i,mname,xname)
  bxname=".exe"'DEFAULT BINARY EXTENSION NAME
  bfname=ParseFileName(s,i,bmname,bxname)
  '
  '
  'ATTEMPT TO GET FILE
  '===================
  '
  t=getfile fname
  if not t then
    pr.in "error 3: file empty or not found: "+fname
    jmp fwd done
  end if
  '
  u=""
  '
  if swc then
    if bfname="" then
      bfname=mname+".exe"
    end if
    u+="#file "+qu+bfname+qu+cr
  end if
  '
  t=u+chr(12)+t
  '
  '
  'NORMAL COMPILE
  '==============

 'o2_mode 0  'read/return null terminated ascii strings
  o2_mode 9   'ascii string (1: byte characters) (8: o2 string)
  '
  select swa
  case "a"  : pr.in o2_prep(t) 'OUTPUT ASSEMBLY CODE
  case "b"  : pr.in o2_view(t) 'OUTPUT O2 MACHINE SCRIPT (AFTER ASSEMBLY CODE)
  case "i"  : pr.in o2_abst(t) 'OUTPUT INTERMEDIATE CODE (BEFORE ASSEMBLY CODE)
  case else :       o2_basic t 'COMPILE TO EXECUTABLE BINARY
  end select
  '
  er=o2_error
  '
  if er then
    pr.in cr+ er
    jmp fwd done
  else
    if swc=0 then
      o2_exec 0
    else
      pr.in cr+"Okay"
    end if
  end if

  done:
  'DISPLAY RESULTS
  sys ho,lew
  string prs=pr.out
  if len(prs) then
   if swm=0 then
      mbox prs
    else
      'sys p=GetCurrentProcess() '-1 parent process
      AttachConsole(-1) 'attach to console of parent process
      output prs
      sys ho=GetStdHandle( STD_OUTPUT_HANDLE )
      if ho<>consout then consout=ho : output prs 'windows 10
      sleep 10
      FreeConsole
    end if
  end if

--- End code ---

Brian Alvarez:

 Hello Charles, what is oxigen? The syntax looks very different to what i am aiming to...
Can you ellaborate?

 By the way, i already implemented ARRAY SORT. Im very close to compiling PluriBASIC in itself as a 64 bit compiler.

Charles Pegge:
Hi Brian,

Oxygen understands the Qbasic/PB genre of Basic syntax, but has additional flexibility, including C notation. It could replace any dependencies on PB or a C compiler at the back-end.

Chris Chancellor:
Hello Brian

PB commands can  be converted directly to Oxygenbasic O2 commands and then  be compile to 64bit exe and dll assemblies

and that O2 also allow for inline assembly which has all the features of PB inline assembly codes.

see the http://www.oxygenbasic.org/forum/index.php
for yourself

and download its latest compiler and sample from
https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasicProgress.zip

Brian Alvarez:

 PluriBASIC is prepared to output code for any platform. So, even if i added an Oxigen mode, i would still like to finish the C++ version.
I also know Qbasic, maybe that will help. I will take a look when i have the chance. :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version