Re: Compiler 101

Jon Masterson <news@scruffyduck.co.uk>
30 Jan 2005 13:56:22 -0500

          From comp.compilers

Related articles
Compiler 101 news@scruffyduck.co.uk (Jon Masterson) (2005-01-22)
Re: Compiler 101 anton@mips.complang.tuwien.ac.at (2005-01-24)
Re: Compiler 101 lfinsto1@gwdg.de (Laurence Finston) (2005-01-24)
Re: Compiler 101 news@scruffyduck.co.uk (Jon Masterson) (2005-01-24)
Re: Compiler 101 news@scruffyduck.co.uk (Jon Masterson) (2005-01-30)
Re: Compiler 101 user_77@hotmail.com (Nobodyzhome) (2005-01-30)
Re: Compiler 101 henry@spsystems.net (2005-02-18)
Re: Compiler 101 one2001boy@yahoo.com (one2001boy@yahoo.com) (2005-02-28)
| List of all articles for this month |
From: Jon Masterson <news@scruffyduck.co.uk>
Newsgroups: comp.compilers
Date: 30 Jan 2005 13:56:22 -0500
Organization: Customer of PlusNet plc (http://www.plus.net)
References: 05-01-067
Keywords: interpreter
Posted-Date: 30 Jan 2005 13:56:22 EST

John has quite rightly suggested that I provide a concrete example of what
I am tryng to compile. I include a complete test example below. Blocks
are iterative loops (except for the first one which runs only once) and the
program stays in them until the exit condition is achieved.


Thanks in advance


Jon


[Is this an existing language syntax that you have to accept, or is it
an example of the things you need to be able to say in some way? -John]






//BOURNEMOUTH TO POPHAM Version 1.
//Jon Masterson Jan 19, 2005


//sets up the initial situation
BLOCK(Init)
            #DEBUG(On)
            #LOCKDOWN(Off)
          CALL(Initialize)
ENDBLOCK()


//This block executes every cycle and changes some weather conditions over
the course of the flight
BLOCK(Global)
          CHANGE(FS_LowerCloudBase:2000ft:1000ft:20m:5m:5)
          CHANGE(FS_LowerCloudCoverage:2:6:20m:5m:5)
          CHANGE(FS_CurrentVisibility:10:2:25m:0m:5)
ENDBLOCK()


BLOCK(WayPoint1)
//warn the pilot if they have not reached the assigned altitude in time
          IFAND(BlockTime > 2m:FS_Altitude < 1500ft:120s)
                    WRITE("Please expedite your climb to 1500ft", Scroll, 10s)
                    INCREMENT(Counter1:1)
          ENDIF()


//three strikes and out - this gives the pilot a total of 6 minutes to
reach 1500 feet before terminating this flight
          IF(Counter1 >= 3:90s)
                    WRITE("Your flight is terminated as you have not reached your
assigned altitude in time", Fixed, 20s)
                    EXIT()
          ENDIF()


//warn the pilot if they are not within +/- 10 degrees of the required
heading
          BEARING(N50*55.20:W001*29.33)
          IFOR(Bearing < 50:Bearing > 70:2m)
                    WRITE("Please watch your heading" Scroll, 10s)
          ENDIF()


// move to next block once the pilot is within 3 nm of the waypoint
          DISTANCE(N50*55.20:W001*29.33)
          IF(Distance < 3:0s)
                    WRITE("Proceed to next waypoint" Scroll, 10s)
                    NEXT()
          ENDIF()


//if the pilot takes more than 20 minutes to reach then they are probably
lost!
          IF(BlockTime > 20m :1m)
                    GOTO(OutOfTime)
          ENDIF()
ENDBLOCK()


BLOCK(WayPoint2)
//now we are looking for the pilot to get within 3 miles of the approach
point to runway 8 at Popham
          DISTANCE(N51*10.89:W001*18.83)
          IF(Distance < 3:0s)
                    NEXT()
          ENDIF()


//limit their time to get to this point as well
          IF(BlockTime > 20m :1m)
                    GOTO(OutOfTime)
          ENDIF()
ENDBLOCK()


BLOCK(Landing)
//if the pilot is within =/- 10 degrees of the runway heading within 90
seconds then let them land otherwise make them go around
          BEARING(N51*11.84:W001*13.93)
          IFAND(Bearing > 71:Bearing < 91:90s)
                    WRITE("Cleared to Land" Scroll, 10s
                    GOTO(Done)
          ELSE()
                    WRITE("You are not line up correctly - go around" Scroll, 10s)
                    GOTO(GoAround)
          ENDIF()
ENDBLOCK()


BLOCK(GoAround)
//wait till they get within 5 nm of the approach point then try for a
landing again
          DISTANCE(N51*10.89:W001*18.83)
          IF(Distance < 5 :0s)
                    GOTO(WayPoint2)
          ENDIF()
ENDBLOCK()


BLOCK(Done)
//Plans should be on the runway when this condition is met and the program
can terminate a successful flight
          IFAND(FS_RadioAltitude < 5ft :FS_IAS < 40:0s)
                    WRITE("Welcome to Popham" Scroll, 10s)
                    EXIT()
          ENDIF()
ENDBLOCK()


BLOCK(OutOfTime)
//dumps the pilot out of the flight
          WRITE("Sorry but you have run out of time to reach this waypoint -
better luck next time" Fixed, 20s)
          EXIT()
ENDBLOCK()




//-----Called Subroutines below
here-------------------------------------------


BLOCK(Initialize)
//Sets up the start weather and other stuff
SETCOUNTER(Counter1:0)
          ALLOWPAUSE(Yes)
          SETCLOUDLAYER(Lower:2000ft:4000ft:500ft:Cirrus:2:0:False)
          SETWINDLAYER(Surface:0ft:500ft:120:10:15:0)
          SETWINDLAYER(Lower:500ft:2500ft:150:15:25:1)
          SETTEMPLAYER(Surface:1500ft:65F:60F)
          SET(FS_CurrentVisibility:10)
          RETURN()
ENDBLOCK()


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.