C Board  

Go Back   C Board > Community Boards > Projects and Job Recruitment

Reply
 
LinkBack Thread Tools Display Modes
Old 05-11-2009, 05:15 PM   #331
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
I've just pushed some more "splitting into separate files" changes.
The minibasic class itself was quite large, and I split out the compiler component into its own files - the compiler.cpp is nearly 700 lines in itself.

[I had to hack about a few other places as well, and I'm not quite happy about the "DEBUGGING" function, but I wanted something that works - I will hopefully fix it up better tomorrow].

And I've just uploaded a new version of the .exe.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.

Last edited by matsp; 05-11-2009 at 05:38 PM.
matsp is offline   Reply With Quote
Old 05-11-2009, 06:41 PM   #332
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 5,034
Excellent. I'll check it out as soon as I have a chance.
Sebastiani is offline   Reply With Quote
Old 05-11-2009, 07:40 PM   #333
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 5,034
Very nice work, matsp. It's a significant improvement.
Sebastiani is offline   Reply With Quote
Old 05-11-2009, 11:32 PM   #334
I have a hat!?
 
Join Date: Apr 2008
Posts: 178
Since it's dissertation hand in day at my old uni, I thought I'd relive last year and have a go at another parsing project. So this is my attempt, along with my old friends flex and bison I've put together an interpreter. It's not an all in one including the editor like yours is, but for giggles I made it into a com object, and to fully immerse myself in last year, buildable from the WDK/DDK build environments. It will execute mbi files from the command line if you change the build type to exe and uncomment the define at the bottom of main/main.cpp.

It seems to work with pitman and the one from Paul's site, but parenthesised expressions in a parenthesised function call like Window((X+9), (R-8)) for example might trip it up. It's an easy workaround so in best MS tradition, it's classified as won't fix.

Lastly, instead of the umpteen thousand word slog, I did something far more fun and chronicled this thread, inspired by medieval themes.

mini-basic - Google Code
adeyblue is offline   Reply With Quote
Old 05-12-2009, 01:44 PM   #335
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 5,034
matsp, I've noticed a couple of bugs in the latest version. For instance, if you run PITMAN and type 'R' to redo a level the redrawing of the options is off. Also, if you try to run REIGN a compile error is generated. Unfortunately, I'll be out of town for a couple of days, so I won't have time to take a closer look at the code until the end of the week.
Sebastiani is offline   Reply With Quote
Old 05-12-2009, 02:05 PM   #336
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Ok, I'll see what I can do...

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-12-2009, 05:37 PM   #337
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Ok, so clearly out implementation is broken:
Code:
Hello0
World
Hello0
World
Ready.
> list
10 FOR I = 1 TO 10
20 PRINT "Hello";
30 PRINT "World"
40 NEXT I
Ready.
>
This is what it looks like in original minibasic:
Code:
Hello World
Hello World
Hello World
Hello World
Ready.
>list
   10 FOR I = 0 TO 10
   20 PRINT "Hello";
   30 PRINT " World"
   40 NEXT I
Ready.
>
Clearly, the ending semicolon is not honoured as "do not produce a newline".

I will go to be now, but I will try to debug it on the train tomorrow.

[By the way, I'm convinced there is no difference between the current and the previous implementation, so I'm pushing some minor code-cleanups - mainly in the clear-screen, avoiding using a vector to store the clear-character, and using FillConsoleXXX functions instead...]

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-13-2009, 03:12 AM   #338
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
I have identified the problem - but as I am at work at present, I can't submit the code (need to set up proxy settings - I may do that later on).

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-13-2009, 11:12 AM   #339
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Fix (all four lines + a bit of "add braces around one-line conditionals) is now in place. New code is not compiled into an executable.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-13-2009, 05:31 PM   #340
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
More messing about with the parsing. Using table to parse keywords, rather than using long if/else chain. Ended up using HORRIBLE syntax for class-member-function-pointers (I had most of the code ready by the time I got home, it took me until now to get the right syntax).

New executable for Paul (or anyone else) to try out as well.

Edit: Submitted another minor update that cleans up the new code a tiny bit.

And this is the line that took 5 hours to write:
Code:
			(((*this)).*((tab[i].emf)))();

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.

Last edited by matsp; 05-13-2009 at 05:42 PM.
matsp is offline   Reply With Quote
Old 05-13-2009, 06:23 PM   #341
Registered User
 
Join Date: Jan 2008
Posts: 635
O_o

This is why I hate working with other people!
They just don't listen!

Seriously though, you could have saved yourself some time if you'd read my notes. (Even if the relevant source is no longer used.)

Soma

link: matsp / minibasic / changeset / da336054aec1 — bitbucket.org
instructions: search the page for (ZSV)
phantomotap is offline   Reply With Quote
Old 05-14-2009, 02:45 AM   #342
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Quote:
Originally Posted by phantomotap View Post
O_o

This is why I hate working with other people!
They just don't listen!

Seriously though, you could have saved yourself some time if you'd read my notes. (Even if the relevant source is no longer used.)

Soma

link: matsp / minibasic / changeset / da336054aec1 — bitbucket.org
instructions: search the page for (ZSV)
Actually, that is the bit that I eventually copied to make this work - but not being used to member function pointers, I didn't quite get the bit about (*this) that you need to give the compiler what object to work on.

I know you said that it was difficult to get it to work, but I didn't realize quite what it was that was difficult, if you see what I mean. I was searching for solutions on the web, but of course the ones I found only use member function pointers from the class within itself.

I'm sorry I upset you...

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-14-2009, 07:58 AM   #343
Registered User
 
Join Date: Jan 2008
Posts: 635
O_o

I guess I should have added a "wink"... or something.

I do hate working with people who don't listen, but that was hyperbole.

"I didn't quite get the bit about (*this) that you need to give the compiler what object to work on."

You shouldn't have to use that syntax. This:

Code:
(this->*tab[i].emf)();
is correct. It just doesn't work on some compilers for whatever magic reasons. (The extra parentheses around the `->*' subexpression are mandated by the standard.) If you only care about GCC and MSVC (not sure about older versions) you can go ahead and change it.

"I found only use member function pointers from the class within itself."

I'm not sure what you mean here.

Soma
phantomotap is offline   Reply With Quote
Old 05-14-2009, 09:16 AM   #344
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
The quoted bit you don't understand was meant to say that when I searched for a member function pointer example (the C++ FAQ for example), I got something like:
Code:
class X
{
     public:
        void (X::*func)();

        void f()  { cout << "Hello, World" << endl; } 
}


X x;
x.func = &f;
(x.*func)();
(I just wrote that from memory, it may not be accurate)
The key ingredient is that it's not calling a member function of X from within the instance x via a data structure OTHER than the class itself. Which requires the complex this-> or *this syntax. And that was the bit I didn't understand - and the error message from the compiler is completely and utterly meaningless [I also managed to get a "internal compiler error" by adding a line with () instead of braces in a struct initializer, which didn't exactly help the process of working...]

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-14-2009, 05:26 PM   #345
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
I just did a bit more refactoring of the code, splitting the interpreter code into it's own files.


--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting textBox1->Text into a basic string. azjherben C++ Programming 5 06-07-2009 08:27 PM
[ANN] New script engine (Basic sintax) MKTMK C++ Programming 1 11-01-2005 10:28 AM
what are your thoughts on visual basic? orion- General Discussions 16 09-22-2005 04:28 AM
VC++ 6 & MASM (eek) ahluka C++ Programming 2 07-16-2005 10:00 AM


All times are GMT -6. The time now is 08:05 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22