BASIC in C++(github.com)
github.com
BASIC in C++
https://github.com/rollbear/basicpp
12 comments
IIRC, Common Lisp has something like this:
I can't decide if this is brilliant or terrifying.
This is why D doesn't have AST macros, a preprocessor, and makes operator overloading difficult for any purpose other than arithmetic.
Programmers can (and do) still create DSLs in D by using string mixins and CTFE.
Programmers can (and do) still create DSLs in D by using string mixins and CTFE.
Fairly mundane. You could do most of it in C89 with cpp.
Wasn't the original Bourne shell also written with (more basic) C preprocessor macros to imitate original ALGOL-style constructs?
Yes. It was the inspiration for the IOCCC (International Obfuscated C Code Competition).
http://www.ioccc.org/faq.html
But the macros were the least of its problems: It allocated memory by trapping SIGSEGV (SIGnal for SEGmentiation Violation; that is, the signal the OS sends a program when it's tried to access memory beyond the region it owns); the function which caught SIGSEGV allocated more RAM. This made it difficult to port sh to the Motorola 68000-based computers which were the first generation of Unix workstations.
http://www.in-ulm.de/~mascheck/bourne/segv.html
https://news.ycombinator.com/item?id=8843951
http://www.ioccc.org/faq.html
But the macros were the least of its problems: It allocated memory by trapping SIGSEGV (SIGnal for SEGmentiation Violation; that is, the signal the OS sends a program when it's tried to access memory beyond the region it owns); the function which caught SIGSEGV allocated more RAM. This made it difficult to port sh to the Motorola 68000-based computers which were the first generation of Unix workstations.
http://www.in-ulm.de/~mascheck/bourne/segv.html
https://news.ycombinator.com/item?id=8843951
If you #define END as "return(0);}" and put "int main(){" at the bottom of basic.hpp, you can have a complete BASIC program with #include "basic.hpp" at the top as the only indication that it's C++.
[1] http://www.antonis.de/qbebooks/gwbasman/chapter%206.html
#include "basic.hpp"
_10: LET X = 1;
// ...
_150: END
I think multiple data types could also be added in a way that mostly fits with BASIC syntax. GW-BASIC uses sigil suffixes on variable names to denote their type:[1] $ String variable
% Integer variable
! Single-precision variable (default)
# Double-precision variable
Something like this might be possible with unions (e.g. _10: LET X.D = 3.14; _20: LET N.I = 42;), or you can tolerate a few different LET macros (LETS, LETI, LETD).[1] http://www.antonis.de/qbebooks/gwbasman/chapter%206.html
] 10 PRINT "HELLO'
] RUN
ERROR
In file included from dummy.cpp:1:
In file included from /usr/include/c++/v1/vector:243:
In file included from /usr/include/c++/v1/__bit_reference:15:
In file included from /usr/include/c++/v1/algorithm:594:
/usr/include/c++/v1/memory:1425:36: error: calling a private constructor of class 'std::__1::unique_ptr<int,
std::__1::default_delete<int> >'
::new ((void*)__p) _Tp(_STD::forward<_Args>(__args)...);
^
/usr/include/c++/v1/memory:1358:14: note: in instantiation of function template specialization
'std::__1::allocator_traits<std::__1::allocator<std::__1::unique_ptr<int, std::__1::default_delete<int> > >
>::__construct<std::__1::unique_ptr<int, std::__1::default_delete<int> >, std::__1::unique_ptr<int,
std::__1::default_delete<int> > &>' requested here
{__construct(__has_construct<allocator_type, pointer, _Args...>(),
^
/usr/include/c++/v1/vector:781:25: note: in instantiation of function template specialization
'std::__1::allocator_traits<std::__1::allocator<std::__1::unique_ptr<int, std::__1::default_delete<int> > >
>::construct<std::__1::unique_ptr<int, std::__1::default_delete<int> >, std::__1::unique_ptr<int,
std::__1::default_delete<int> > &>' requested here
__alloc_traits::construct(__a, _STD::__to_raw_pointer(this->__end_), *__first);
^
/usr/include/c++/v1/vector:924:9: note: in instantiation of function template specialization
'std::__1::vector<std::__1::unique_ptr<int, std::__1::default_delete<int> >,
std::__1::allocator<std::__1::unique_ptr<int, std::__1::default_delete<int> > >
>::__construct_at_end<std::__1::unique_ptr<int, std::__1::default_delete<int> > *>' requested here
__construct_at_end(__x.__begin_, __x.__end_);
^
dummy.cpp:7:37: note: in instantiation of member function 'std::__1::vector<std::__1::unique_ptr<int,
std::__1::default_delete<int> >, std::__1::allocator<std::__1::unique_ptr<int, std::__1::default_delete<int> > >
>::vector' requested here
std::vector<unique_ptr<int>> bar = foo;
^
/usr/include/c++/v1/memory:1997:5: note: declared private here
unique_ptr(const unique_ptr&);
^
1 error generated.templates are a inappropriate macro language. Everyone knows this except the C++ aficionados.
I'm still liking Visual BASIC 6.0 before the Dotnet era.
A shame that newer versions of Windows have problems installing it.
There is Jabaco that takes VB 6.0 syntax and compiles it to Java bytecode: http://www.jabaco.org/
It doesn't have ADO database support so I can't write apps with Databases in VB 6.0 and port them to Jabaco.
This trying to make C++ do BASIC commands is hard, might as well use this instead: http://robhagemans.github.io/pcbasic/
You can find the Classic BASIC games here: http://www.vintage-basic.net/games.html
They should work with PC-BASIC.
A shame that newer versions of Windows have problems installing it.
There is Jabaco that takes VB 6.0 syntax and compiles it to Java bytecode: http://www.jabaco.org/
It doesn't have ADO database support so I can't write apps with Databases in VB 6.0 and port them to Jabaco.
This trying to make C++ do BASIC commands is hard, might as well use this instead: http://robhagemans.github.io/pcbasic/
You can find the Classic BASIC games here: http://www.vintage-basic.net/games.html
They should work with PC-BASIC.
I remember of "on error resume next".
I also made ActiveX. It was a very good IDE.
I also made ActiveX. It was a very good IDE.
I did something similar in C but I called it HereC. I mostly just did #define begin { and #define end } the other thing I did was make && to AND and || to OR was fun for a few minutes, then I never went back to it.
But part of that was already done for you in iso646.h!
http://en.cppreference.com/w/cpp/language/operator_alternati...
http://en.cppreference.com/w/cpp/language/operator_alternati...
If you'd like to fool around with an Applesoft BASIC compatible interpreter that comes with almost 1000 listings, check out DiscoRunner http://discorunner.com
That's wonderful/abusive. There used to be a macro assembler for the Apple ][ that came with an add-on package of macros that provided a BASIC-like language. It was heavily advertised in Nibble Magazine.
It seems someone managed to dig it up, collect some recollections by the author and demo it a few years ago:
http://www.kansasfest.org/wp-content/uploads/2010-neubauer-m...
https://vimeo.com/13739643
Circle is complete.
It seems someone managed to dig it up, collect some recollections by the author and demo it a few years ago:
http://www.kansasfest.org/wp-content/uploads/2010-neubauer-m...
https://vimeo.com/13739643
Circle is complete.
Here's a version in Haskell implemented using a monadic DSL: http://augustss.blogspot.in/2009/02/more-basic-not-that-anyb...
Also, here's ASM embedded in Haskell: http://wall.org/~lewis/2013/10/15/asm-monad.html
Also, here's ASM embedded in Haskell: http://wall.org/~lewis/2013/10/15/asm-monad.html
> Only numeric variables are supported (no strings, no matrices)
Basic.hpp defines LET as:
Basic.hpp defines LET as:
#define LET double [1]
Perhaps this would allow for a broader range of types, seen as C++11 is being used: #define LET auto
[1]: https://github.com/rollbear/basicpp/blob/master/basic.hpp#L8...