Make your own free website on
-- Look out! We be programming!
-- cradle2a.ex a Euphoria compiler by A.R.S. KA9QLQ Alvin Koffman Copy right 2002

-- cradle2a.ex

include get.e -- for get character functions
include wildcard.e -- for upper()

with trace
--trace(1) -- output to screen

  alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", -- Define alphas
  nums = "0123456789"	-- Define numerics

 object Look	-- Look ahead character

procedure GetChar() -- this grabs a line of characters
   Look = getc(0)			 --	this will prosess one character at a time if looped
end procedure

function IsAlpha(object c) -- Recognize an Alpha Character
   return find(upper(c),alpha)
end function

function IsDigit(object c) -- Recognize a Decimal Digit
   return find(c,nums)
end function

procedure Error(sequence s) -- Report an Error
   puts(1,"\n Error: " & s & ".")
end procedure

procedure Abort(sequence s) -- Report Error and Halt
atom x
   Error(s) -- call to get the error
   x = wait_key() -- wait so you can see results
   abort(1)	   -- when using Windows or Linux
end procedure

procedure Expected(sequence s) -- Report What Was Expected
   Abort(s & " Expected")
end procedure

function GetNum() -- Get a Number
object x				-- check for error and return results
   if not find(Look,nums) then Expected("Integer")
   end if
   x = Look
   return x
end function

procedure Init()  -- Initialize
   GetChar() -- grab a character
end procedure

procedure Expression() -- output assembly code for numerics
   puts(1, "MOVE # " & GetNum() & " D0 \n")
end procedure

-- start
   puts(1, "Input a line of characters \n") -- ask for imput
   Init()    -- call initialison procedure
   Expression()  -- check for and process numbers