Re: Ewl

new topic     » goto parent     » topic index » view thread      » older message » newer message

Philip,
I've inserted an updated version of ewl.ex here.

The main two changes were that I used 'concatenate' rather than 'append' to
join the instructions from the file together, secondly, I introduced an
instruction pointer to be used as an index into the sequence holding the
instructions.

--------
include get.e
include machine.e
include sort.e
include wildcard.e
include input.e

with trace

sequence command
puts(1,
 "Do you wish to trace ? (Y) / (N):\n ")
 command = upper(user_input())
 if 'Y' = command[1] then
    trace(1)
    end if

    if 'Y' = command[1] then
    trace(1)

    elsif 'N' = command[1] then
    trace(0)
    end if


object temp
temp = command_line()

if length(temp) <= 2 then
puts(1,"No program file selcted, Aborting")
abort(42)
end if

sequence runfile,PS
atom file

PS = {}

runfile=temp[3]
file= open(runfile,"r")

if file = -1 then
printf(1,"%s does not exist, or you have got the wrong path",{runfile})
abort(42)
end if

temp = gets(file)

while not atom(temp) do

    -- Concatenate rather than append
    PS &= temp

    temp = gets(file)

end while

integer ip -- This is the "instruction pointer"

-- Set to start at the first instruction.
ip = 1

-- This loops until there are no more instructions.
-- Each iteration looks at ONE instruction.
-- When the instruction is identified, it is executed
-- and the IP is updated to point to the next instruction to execute.
while ip <= length(PS) do

if compare(PS[ip], 'a') = 0 then
  abort(42)

elsif compare(PS[ip],'h') = 0 then
  puts(1,"Hello")
  ip += 1
else
  ip += 1
end if

end while


----------
cheers,
Derek
----- Original Message -----
From: Philip Mullen
To: EUforum
Sent: Saturday, February 16, 2002 9:31 PM
Subject: Ewl



Hello, for the last couple of days i have been working with the euphoria
gets command as i am trying ti see how easy it is to create my own langugae,
it is extremly limited but i just want to try, But I can't seem to get the
program to read in the command and then take the proper action, if any one
out there can see why could they send me an ammended version and the notes
to how they did it?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu