GithubHelp home page GithubHelp logo

fogus / baysick Goto Github PK

View Code? Open in Web Editor NEW
246.0 16.0 41.0 73 KB

An embedded Insane-specific Language for Scala implementing the BASIC programming language

Home Page: http://blog.fogus.me/2009/03/26/baysick-a-scala-dsl-implementing-basic/

License: MIT License

Scala 100.00%
langdev

baysick's Introduction

BAYSICK - an embedded Insane-specific Language for Scala implementing a subset of BASIC

Here is a small example:

    object SquareRoot extends Baysick {
      def main(args:Array[String]) = {
        10 PRINT "Enter a number"
        20 INPUT 'n
        30 PRINT "Square root of " % "'n is " % SQRT('n)
        40 END
    
        RUN
      }
    }

Here is a larger example

    object Lunar extends Baysick {
      def main(args:Array[String]) = {
        10 PRINT "Welcome to Baysick Lunar Lander v0.0.1"
        20 LET ('dist := 100)
        30 LET ('v := 1)
        40 LET ('fuel := 1000)
        50 LET ('mass := 1000)
    
        60 PRINT "You are a in control of a lunar lander."
        70 PRINT "You are drifting towards the surface of the moon."
        80 PRINT "Each turn you must decide how much fuel to burn."
        90 PRINT "To accelerate enter a positive number, to decelerate a negative"
    
        100 PRINT "Distance " % 'dist % "km, " % "Velocity " % 'v % "km/s, " % "Fuel " % 'fuel
        110 INPUT 'burn
        120 IF ABS('burn) <= 'fuel THEN 150
        130 PRINT "You don't have that much fuel"
        140 GOTO 100
        150 LET ('v := 'v + 'burn * 10 / ('fuel + 'mass))
        160 LET ('fuel := 'fuel - ABS('burn))
        170 LET ('dist := 'dist - 'v)
        180 IF 'dist > 0 THEN 100
        190 PRINT "You have hit the surface"
        200 IF 'v < 3 THEN 240
        210 PRINT "Hit surface too fast (" % 'v % ")km/s"
        220 PRINT "You Crashed!"
        230 GOTO 250
        240 PRINT "Well done"
    
        250 END
    
        RUN
      }
    }

Enjoy.

note: The BASIC programming language is 50 years old

License

Copyright 2010-2014, Michael Fogus Licensed under the MIT License.
Redistributions of files must retain the above copyright notice.

baysick's People

Contributors

abremod avatar aerben avatar fogus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

baysick's Issues

Move to SBT

Just a suggestion. SBT will help you run tests and build easier.
Right now it looks like tests are run via a shell script.

Add GOSUB

Baysick should support subroutines. They would work something like this:

```
10 PRINT “Subroutine test”
20 LET (‘a := 0)
30 PRINT "Variable is " % ’a // prints 0
40 GOSUB inc
50 PRINT "Variable is " % ’a // prints 1
60 SUB “inc”
70 LET (’a := ’a + 1)
80 RETURN
90 GOSUB 60
100 PRINT "Variable is " % ’a // prints 2
110 END
```

-m

compatibility issue.

on line 194:
replace

def RUN() = gotoLine(lines.keys.toList.sort((l,r) => l < r).first)

with

def RUN() = gotoLine(lines.keys.toList.sortWith((l, r) => l < r).head)

I believe on Scala 2.10+ (that I have tested) the sort definition is not available anymore.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.