Compiler for Standard Beta

image_pdfimage_print

Work has been started to write a compiler for standard Beta – now StdBeta, using the VM for qBeta and proving an interface to qBeta to StdBeta.

Status is as follows:

  • The parser seems to be complete
  • The checker is incomplete
    • Search of names and links to declarations has been implemented
    • Virtual bindings have been implemented
    • Type checking has not been implemented
      • This includes type checking for virtual patterns
  • Code generation has been partially implemented
    • A VM class is generated for each StdBeta pattern
    • The class code contain the parts: allocation, enter, do, and exit as in the original StdBeta compiler
    • Storage allocation has been implemented for data items and virtual patterns VDT
    • Part objects have been implemented with respect to generation as part of holder object. Currently not inlined.
    • Primitive expressions have been implemented
    • Assignment has been implemented – check reference assignment
    • Pattern generation has been implemented
    • Invocation of objects, within enter and exit part
    • Code for enter-part should scan enterlist in reverse – currently missing
    • Code for exit-part may have a similar problem
    • Multiple assignment as in foo -> (x,y,z) has not been implemented
    • This ptn is not implemented
    • ComputedRemote has not been implemented
    • Var patterns (P##) have not been implemented.

Interface to StdBeta

It is possible to interface to a Beta fragment with origin in betaenv.

  • The qBeta module must have a supplementary property %betamodule <BetaFragment-path> where the latter is the path to the Beta fragment
  • Patterns in the Beta fragment may then be invoked from qBeta
  • The qBeta compiler automatically generates q qBeta interface to a givne Beta pattern
  • Currently only primitive values can be used as parameters (enter/exit)
  • Currently a (empty) program fragment must be defined in the Beta fragment

Example

An example of a StdBeta fragment

betafrag.bet
ORIGIN '~beta/basiclib/betaenv';
---program:descriptor---
(##)
---lib:attributes:attributes---
foo:
   (# x,y,z: @integer
   enter(x,y)
   do x + y -> z
   exit z
#)

This fragment can be used as follows

qbetaEx: obj
   %betamodule "~beta/exlib/betafrag'
   V: var integer
   V := foo(111,222)