Who of us are programmers and what are you working right now?

Varine

And as the moon rises, we shall prepare for war
Reaction score
808
My programs clearly portray my frustration when you go through the source. Especially in the comments once I get too drunk to keep programming.
 

camelCase

The Case of the Mysterious Camel.
Reaction score
362
I've never tried coding while drunk =/ Does it help you solve problems more creatively? =P
 

camelCase

The Case of the Mysterious Camel.
Reaction score
362
Tadah!
First boss of the game.

Edit:
Also, s3rius. I took the time to actually read the thing, play with the example, run it through the debugger and follow it through its execution but I only understood the tokenizer =/

The whole parser thing is alien to me; I half want to blame the horrible naming conventions =P I probably don't get it because I've never learned anything compiler related before =/

Edit:
Okay, I just made another attempt and decided to only implement a very small portion of the parser and I managed to get "4+4+pi*2;" working. Yes, I know that the "proper" parser would fail this statement but I'm only implementing a small portion.

One thing I see repeating again and again is shown in this snippet:
Code:
var prefix = function (id, nud) {
    var s = symbol(id);
    s.nud = nud || function () {
        scope.reserve(this);
        this.first = expression(70);
        this.arity = "unary";
        return this;
    };
    return s;
}

The part I don't get is why [ljass]arity[/ljass] is set when fuction [ljass]nud[/ljass] is called. Why not set the variable when the instance is being instantiated?

Like, why not this?
Code:
var prefix = function (id, nud) {
    var s = symbol(id);
    s.nud = nud || function () {
        scope.reserve(this);
        this.first = expression(70);
        return this;
    };
    this.arity = "unary";
    return s;
}

Also, this being a unary operator, it has a left binding power of 70. However, this value isn't being passed to [ljass]this.lbp[/ljass] at all. Instead, it's being passed as a literal directly to the call to [ljass]expression()[/ljass].. I'm confused..

Edit:
Oh, I just got it an lbp isn't set because symbol() can potentially return an existing instance of a symbol with that id.. And this prefix doesn't want to override that..

Oh... And the arity is modified only when it is used specifically as a unary operator..

I understand now but it doesn't seem like a, I duno, like a good way to handle it..
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
Oh... And the arity is modified only when it is used specifically as a unary operator..

I understand now but it doesn't seem like a, I duno, like a good way to handle it..

Keep in mind that this is implementation detail. In my implementation I don't have an arity at all.
The key thing is the idea of assigning a nud/led/lbp to each token and parsing different precending levels.

My previous parser was a typical recursive descent parser, and - true to its name - it had to do a lot of recursion and backtracking to get more complex expression right.
This TDOP method on the other hand.. there's hardly any backtracking at all: if a term couldn't be resolved in its first pass, it's malformed.

That's really cool.
 

camelCase

The Case of the Mysterious Camel.
Reaction score
362
I actually spent a lot more time on it and I think I'm finally wrapping my head around it. Some where in the middle, I thought to myself, "Screw it, I'll try following using a strongly typed language".

And I've got progress ;)
You'll see some bugs in the screenshots, I've fixed those since. I just didn't feel like taking another screen shot =/
testRawTokenizer.png
Parser.png

Parser2.png


I've only implemented a small subset of the parser and the tokenizer and deviated from the example given but I think I get what I'm doing (finally). I'm probably getting all the terminology wrong and all, though =P

My take on it is that there are three things:
RawToken
Symbol
Token

A whole bunch of RawToken instances is created from the input code. The Symbol has a nullDenotator() and leftDenotator() method. They both return an instance of Token.

RawToken has the following variables and methods:
+ rawType (literal, name, operator, etc.)
+ value
+ start (I don't use the start variable)
+ end (I do use the end variable for forming the tokens)

Symbol has the following variables and methods:
+ id
+ value
+ leftBindingValue
+ nullDenotator()
+ leftDenotator()

Token has the following variables and methods:
+ arity
+ value
+ first (or left)
+ second (or right)
(Note that I haven't gotten to doing ternary operators yet..)

Now that you mention a lack of arity in your implementation, I can kinda' see why it's redundant.. I think.
Unary: second is null
Binary: first and second not null
Literal: first and second is null

Or am I missing the point? =x
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
Yea, that's pretty much all that arity is about.

Right now I'm using polymorphism:

Code:
class BinaryNode : public ASTNode{
    BinaryOp m_op;
    ASTNode *m_left, *m_right;
    ....
};
 
class UnaryNode : public ASTNode{
    UnaryOp m_op;
    ASTNode *m_node;
    ....
};
....

If you put all the node processing into the classes itself there's absolutely no need to have an arity variable.

Nice screenies by the way. I'm still using console and txt files :3

jfXeK44.png
 

Mahucharn

I wear a fez now, fezzes are cool.
Reaction score
173
I start Intro to Comp Sci-1 at my school in 2 weeks... that counts, right? Should be learning raquet as well. Oh also, I'm the webmaster's assistant for my school, so I just made a new archive system using HTML and PHP.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top