9

I have been challenged by a friend to write a QBasic compiler in QBasic.

Where can I find a language specification for the latest version of the language?

eoredson
  • 1,167
  • 2
  • 14
  • 29
Simon Johnson
  • 7,802
  • 5
  • 37
  • 49
  • 1
    Do you mean QBasic 1.1 or QuickBasic 4.5? – Cody Gray - on strike Dec 18 '10 at 08:53
  • 1
    The challenge states the QBasic interpreter that shipped with the earlier versions of Windows. The compiler must run on that version of QBasic and must be capable of compiling itself. I guess that would mean QBasic 1.1. – Simon Johnson Dec 18 '10 at 08:58
  • 3
    You're in for quite a challenge, given that QBasic is an interpreted language and can't actually compile code. – Cody Gray - on strike Dec 18 '10 at 09:08
  • 1
    A bit of back story - the conversation came about because we lamented that QBasic didn't have a binary compiler that we could use at school. All our code had to be interpreted through QBasic, at the time I wished I'd had the ability to write a compiler in QBasic so I could actually produce binaries. This challenge is the fufil this childhood dream - make a compiler to boostrap Qbasic from an interpreted language to a compiled language. – Simon Johnson Dec 18 '10 at 09:47
  • 4
    Funny thing is, the QBasic that shipped with MS-DOS is just a stripped down version of QuickBASIC (IIRC 4.0, possibly 4.5) that had the compiler, binary tools, and "quicklib" support removed. – Chris Charabaruk Jun 27 '11 at 07:35
  • 1
    @SimonJohnson, were you able to build this? I'm looking for a way to build an interpreter for the QBASIC (or variant) that would run on Windows 8. I would use another language that runs on a modern OS. I know you can use a DOS VM but I'd like to write one that runs on the machine itself. btw: Writing an interpreter of a language in the same language is called meta-circular interpretation. http://en.wikipedia.org/wiki/Meta-circular_interpretation – Adam Mendoza Aug 24 '14 at 03:16
  • You can't compile Qbasic using Qbasic without the source to Qbasic. Try QB64 instead -- it CAN compile itself. – eoredson Aug 27 '16 at 03:44
  • 3
    To reduce the confusion, no, QBasic/QuickBasic wasn't/isn't compiled in existing, traditional implementations but at the end of the day, there's no reason QBasic code couldn't be compiled in the same sense that any code could be compiled if someone wrote a compiler for it. – Robert Talada Apr 08 '18 at 22:49

4 Answers4

5

QB64 is a nice clone/extension of QBasic which has a wiki that contains a very detailed language reference sorted alphabetically, by usage, or syntactically.

Note: keywords prefixed with an underscore ('_') are extensions that were NOT part of the classic QBasic language.

rsiemens
  • 615
  • 6
  • 15
veganaiZe
  • 539
  • 5
  • 13
4

Microsoft's QBasic IDE comes with fairly complete documentation of the language and provided routines. So far as I know, that is about as complete a specification as you'll find, but it should be enough to write a compiler for (most of) the language, aside from undocumented DOS-specific peek/poke magic.

Michael Ekstrand
  • 28,379
  • 9
  • 61
  • 93
2

QuickBasic 4.5 can compile into *.exe

0

You can find the latest version by just typing in your browser: QB64 - it's how it is nowadays called/redone version of QBasic with a bigger aspect of opportunities. They have their forum, YT Channel and even Discord.

RaLe
  • 99
  • 9