[QUOTE=Dj-J3;34001267][img]http://dl.dropbox.com/u/4912307/ClipboardUploader/2012-01-01_23_07_19_499.png[/img]
Fuck yea[/QUOTE] Textures are not ripped off from Terraria.
[QUOTE=r0b0tsquid;34001149]in C++, I can just throw the return value and catch it in the function call[/QUOTE]
uhm, you're throwing return values? :v:
[QUOTE=synthiac;34000283]thanks i definitely wasn't aware of that at all[/QUOTE]
Except you said you werent in your other post, but ok
Wow, didn't expect that many comments :v:
The parser works on recursive descent - there are a set of functions that call each other in a recursive manner - the tokens are "eaten" left-to-right, but the nested functions ensure that the parsed tokens are assemble in the correct order.
Unfortunately, this means that the return takes place inside of a nested set of functions - it could be statement (function call) -> block -> statement (return), or something like call->block-> if -> block -> return. The problem is, if you just return the value from the (C++) function (as you could reasonably expect to be able to do), the if statement is still expecting its end token, along with any other blocks that you're inside, even though you've jumped back to the position of the function call.
Picture it: the program sees an if, and it expects to see an end after it's finished the block. If you've returned from somewhere inside that block, the "if" still expects its "end".
The throwing of the return values isn't just for the sake of returning the values - if that were the case, I'd just return it from the function. The whole point of throwing is to drop back up through the (machine's) call stack, so that the parser doesn't still expect ends for its ifs etc.; the returning of the value through the same mechanism is more because it's convenient than out of necessity.
[editline]1st January 2012[/editline]
Anyway, here's what I came here to post:
[img]http://i.imgur.com/ixOkX.png[/img]
Intensity plots :) I'll do march squares on the field and draw some actual lines and polys tomorrow, I'm feeling like I ought to go to bed soon.
[QUOTE=r0b0tsquid;34002278]Wow, didn't expect that many comments :v:
The parser works on recursive descent - there are a set of functions that call each other in a recursive manner - the tokens are "eaten" left-to-right, but the nested functions ensure that the parsed tokens are assemble in the correct order.
Unfortunately, this means that the return takes place inside of a nested set of functions - it could be statement (function call) -> block -> statement (return), or something like call->block-> if -> block -> return. The problem is, if you just return the value from the (C++) function (as you could reasonably expect to be able to do), the if value is still expecting its end token, along with any other blocks that you're inside, even though you've jumped back to the position of the function call.
Picture it: the program sees an if, and it expects to see an end after it's finished the block. If you've returned from somewhere inside that block, the "if" still expects its "end".
The throwing of the return values isn't just for the sake of returning the values - if that were the case, I'd just return it from the function. The whole point of throwing is to drop back up through the (machine's) call stack, so that the parser doesn't still expect ends for its ifs etc.; the returning of the value through the same mechanism is more because it's convenient than out of necessity.
[editline]1st January 2012[/editline]
Anyway, here's what I came here to post:
[img]http://i.imgur.com/ixOkX.png[/img]
Intensity plots :) I'll do march squares on the field and draw some actual lines and polys tomorrow, I'm feeling like I ought to go to bed soon.[/QUOTE]
You're so damn productive you make me feel bad.
[img]http://dl.dropbox.com/u/6470891/townsKINDOF%21.png[/img]
Towns! Kind of!
Need to improve the sprite to fuck and make it bigger, but eh later.
And of course, at the moment they contain...
[img]http://dl.dropbox.com/u/6470891/OHMYGODITSSHITALL.png[/img]
[i]ABSOLUTELY SHIT ALL BECAUSE FUCK PROGRESS SERIOUSLY[/i]
[QUOTE=Funley;34001756]Textures are not ripped off from Terraria.[/QUOTE]
Why does it matter
[QUOTE=r0b0tsquid;34002278]Wow, didn't expect that many comments :v:
The parser works on recursive descent - there are a set of functions that call each other in a recursive manner - the tokens are "eaten" left-to-right, but the nested functions ensure that the parsed tokens are assemble in the correct order.
Unfortunately, this means that the return takes place inside of a nested set of functions - it could be statement (function call) -> block -> statement (return), or something like call->block-> if -> block -> return. The problem is, if you just return the value from the (C++) function (as you could reasonably expect to be able to do), the if statement is still expecting its end token, along with any other blocks that you're inside, even though you've jumped back to the position of the function call.
Picture it: the program sees an if, and it expects to see an end after it's finished the block. If you've returned from somewhere inside that block, the "if" still expects its "end".
The throwing of the return values isn't just for the sake of returning the values - if that were the case, I'd just return it from the function. The whole point of throwing is to drop back up through the (machine's) call stack, so that the parser doesn't still expect ends for its ifs etc.; the returning of the value through the same mechanism is more because it's convenient than out of necessity.[/QUOTE]
That sounds... wrong. So returning stops the parser and you could write invalid code after it? Even more, executing the code at the same time as parsing? Usually parsers build a syntax tree, which is then used for (possibly) optimizing and executing or compiling.
Instead of doing real work, I'm implementing a VM/CPU-based challenge for a crackme compo.
It's getting turing-complete!
[img]http://i.imgur.com/1ozM5.png[/img]
Also, I have the best scriptable assembler ever :v:
[img]http://i.imgur.com/ATI5r.png[/img]
The program is loaded at 0xc0000000, 0xb0000000 is memmapped IO. Now to implement a stack...
How does that scriptable assembler work anyway
(Is that lua?)
[QUOTE=esalaka;34003641]How does that scriptable assembler work anyway
(Is that lua?)[/QUOTE]
It's python. It's basically a half-arsed script that exposes an assemble method, which eats assembler code and spits out bytecode (which I append to a buffer). And since this is actually bloody Python, I can do some weird stuff, like that label (which is a variable containing the address of the label) and jump to it (where the jump target is calculated based on where the code is loaded to, and the label value). Think of it as a preprocessor on steroids. :v:
...I'd actually love to see Python used as a preprocessor for C++.
[QUOTE=esalaka;34003641]How does that scriptable assembler work anyway
(Is that lua?)[/QUOTE]
Looks more like python
[editline]1st January 2012[/editline]
You ninja.
[IMG]http://i.imgur.com/yTSm4.png[/IMG]
Not sure what this is yet. Basically it's just a simple test to get the Java 2D canvas working, instead of using any graphics libraries like LWJGL. Right now entities, player input, and collisions work, and so do particles. Not bad considering it was written from scratch 3 days ago (for me :v:)
I had a revelation today related to programming
The best ideas come to you while you're on the toilet squeezing one out, right?
I went and put a notepad and pen in my bathroom. Now I'll be able to write down my ideas.
My new years resolution is to stop being a lazy dickhead and practice programming at least once a week (not going to happen), so I started with a few things I might want to have at hand in the future, and this is what I came up with:
[img]http://puu.sh/c9Ea[/img]
The context menu object is basically built up with a bunch of button objects inside a table, so it's pretty easy to set one up, and I made sure that telling the context menu what each button does was a piece of cake too.
[QUOTE=NovembrDobby;33999779]Shaders in SFML are well easy
[img]http://i.imgur.com/vvLin.gif[/img][/QUOTE]
Are you still using SFML 1.6? if so how are you finding not having rendertargets?
[QUOTE=Quark:;34004123]I had a revelation today related to programming
The best ideas come to you while you're on the toilet squeezing one out, right?
I went and put a notepad and pen in my bathroom. Now I'll be able to write down my ideas.[/QUOTE]
Bring a laptop to the bathroom, instant access to everything in your time of need
[QUOTE=Richy19;34004366]Are you still using SFML 1.6? if so how are you finding not having rendertargets?[/QUOTE]
Nope, switched over almost straight away
Digitally synthesized sine wave:
[img]http://i56.tinypic.com/21c8q38.png[/img]
Okay, apparently by changing a local variable copy of my resolution, I'm changing the global variable. :v:
[editline]1st January 2012[/editline]
What the hell, I made the local table a copy (as in local ts = {} for k, v in pairs(SETTINGS) do ts[k] = v end) and it STILL changes the global variable
[editline]1st January 2012[/editline]
Okay, fixed it. It was just passing on the reference to the vector object I was using
[QUOTE=r0b0tsquid;33999825]Are you parsing the strings directly? As in, if you put a space, newline etc. between "x" and "=", would it still parse correctly? If it does, is that because you're manually skipping over the spaces or because you're doing some form of tokenization? One of the things that made my life a lot easier with the VB6 grapher was breaking strings down into tokens (IDs, Numbers and whatnot) before I began parsing :)[/QUOTE]
The full output with debug:
[code]
>>> Ab = """
x = 0;
y = 10;
z = 100;
x = x + (y*z)/2;
ab = x+(y*z)/2;
x;
y;
z;
ab;
"""
>>> run(Ab)
Parsing:
x = 0
['x', '=', '0']
Parsing: x
['x']
Parsing: 0
['0']
Asigning x to 0.0
Parsing: 0.0
['0.0']
0.0
Parsing:
y = 10
['y', '=', '10']
Parsing: y
['y']
Parsing: 10
['10']
Asigning y to 10.0
Parsing: 10.0
['10.0']
10.0
Parsing:
z = 100
['z', '=', '100']
Parsing: z
['z']
Parsing: 100
['100']
Asigning z to 100.0
Parsing: 100.0
['100.0']
100.0
Parsing:
x = x + (y*z)/2
['x', '=', 'x', '+', '(y*z)', '/', '2']
Parsing: x
['x']
Parsing: x+(y*z)/2
['x', '+', '(y*z)', '/', '2']
Parsing: x
['x']
Parsing: (y*z)/2
['(y*z)', '/', '2']
Parsing: (y*z)
['(y*z)']
Ignoring outer parens.
Parsing: y*z
['y', '*', 'z']
Parsing: y
['y']
Parsing: z
['z']
Parsing: 2
['2']
Asigning x to 500.0
Parsing: 500.0
['500.0']
500.0
Parsing:
ab = x+(y*z)/2
['ab', '=', 'x', '+', '(y*z)', '/', '2']
Parsing: ab
['ab']
Parsing: x+(y*z)/2
['x', '+', '(y*z)', '/', '2']
Parsing: x
['x']
Parsing: (y*z)/2
['(y*z)', '/', '2']
Parsing: (y*z)
['(y*z)']
Ignoring outer parens.
Parsing: y*z
['y', '*', 'z']
Parsing: y
['y']
Parsing: z
['z']
Parsing: 2
['2']
Asigning ab to 1000.0
Parsing: 1000.0
['1000.0']
1000.0
Parsing:
x
['x']
500.0
Parsing:
y
['y']
10.0
Parsing:
z
['z']
100.0
Parsing:
ab
['ab']
1000.0
[/code]
As you can see, I'm tokenizing it. But I don't know how I'd define special syntax like a for loop or a ternary operator (or a unary operator like ++ (actually, even += is difficult because I already have a + operator and an = operator, so it'll parse it as '+', and '='))
[editline]1st January 2012[/editline]
Since when do code tags not have a scroll bar?
[QUOTE=bobthe2lol;34004942]The full output with debug:
As you can see, I'm tokenizing it. But I don't know how I'd define special syntax like a for loop or a ternary operator (or a unary operator like ++ (actually, even += is difficult because I already have a + operator and an = operator, so it'll parse it as '+', and '='))
[editline]1st January 2012[/editline]
Since when do code tags not have a scroll bar?[/QUOTE]
Have a list of operators and sort them by length, then go through them one by one and look for them in the code. That way == will come before = and be parsed correctly.
[QUOTE=bobthe2lol;34004942]As you can see, I'm tokenizing it. But I don't know how I'd define special syntax like a for loop or a ternary operator (or a unary operator like ++ (actually, even += is difficult because I already have a + operator and an = operator, so it'll parse it as '+', and '='))[/QUOTE]
recursive descent handles 'special' syntax for you:
[img]http://i.imgur.com/GQbeM.png[/img]
As for different tokens with the same prefix, just order them by length and your lexer will pick them up as it should:
[img]http://i.imgur.com/yypU9.png[/img]
[QUOTE=swift and shift;34005214]recursive descent handles 'special' syntax for you:
[img]http://i.imgur.com/GQbeM.png[/img][/QUOTE]
Err I'm not familiar with these terms. I just sort of wrote this, all the resources I could find online were way too technical and abstract, even when they give you code. Recursive descent? My expression class is recursive, it creates left and right expressions around the most important operator, and then tells the operator to operate on them (each operator is a class with an importance variable and an operate method which takes a left and right value). Sorting by length I can do, but how do I determine weather an operator is unary, binary or ternary, and weather each operator is prefix, infix or postfix (in the list of tokens that is). For example, '-2' is tokenized (correctly I assume) as ['-','2'], but how do I differentiate that operation (2*-1) from the subtraction operator?
[QUOTE=bobthe2lol;34005728]Err I'm not familiar with these terms. I just sort of wrote this, all the resources I could find online were way too technical and abstract, even when they give you code. Recursive descent? My expression class is recursive, it creates left and right expressions around the most important operator, and then tells the operator to operate on them (each operator is a class with an importance variable and an operate method which takes a left and right value). Sorting by length I can do, but how do I determine weather an operator is unary, binary or ternary, and weather each operator is prefix, infix or postfix (in the list of tokens that is). For example, '-2' is tokenized (correctly I assume) as ['-','2'], but how do I differentiate that operation (2*-1) from the subtraction operator?[/QUOTE]
I learned a lot from this article: [url]http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/[/url] Perhaps it can help you too
[vid]http://j.mp/rFHQSn[/vid]
awww yeaah. quad trees are awesome.
The blobs turn red when they collide.
[editline]asdf[/editline]
[img]http://j.mp/upROcr[/img]
aaaa I can't believe how little CPU this uses.
It's not much, but I made a driver for this 4 Digit LED display with Arduino: [IMG]http://img28.imageshack.us/img28/787/screenshot2012010120461.png[/IMG]
[QUOTE=Zeh Matt;34001132]Even ollys analyzer cuts the code at some point without stepping, same goes to IDA, its not any better really
Wasnt that hard to break analyses like that[/QUOTE]
how does the speed get influenced by your protection?
Also are you going to release the protector? I will need one in some time, if you need someone to beta test i'd be happy to help
-snip-
[QUOTE=bobthe2lol;34005728]For example, '-2' is tokenized (correctly I assume) as ['-','2'], but how do I differentiate that operation (2*-1) from the subtraction operator?[/QUOTE]
Ok so what you'd do is have a different 'expression' production for each precedence level, then it doesn't matter that two different operations (subtract and negate) have the same symbol as their operator because it's decided by precedence:
eg: (in abusive pseudo code)
[code]
def additive_expression():
left = multiplicative_expression()
while peek_token() == '+' or peek_token() == '-':
if peek_token() == '+':
next_token()
left = new Add(left, multiplicative_expression())
else if peek_token() == '-':
next_token()
right = new Subtract(left, multiplicative_expression())
return left
def multiplicative_expression():
left = unary_expression()
while peek_token() == '*':
next_token()
left = new Multiply(left, unary_expression())
return left
def unary_expression():
if peek_token() == '-':
return new Negate(unary_expression())
if peek_token() is a number:
return new Number(next_token())
[/code]
[editline]2nd January 2012[/editline]
In fact, if you want to see something that works, try this: [url]http://charlie.bz/maths/parser.js[/url]
Sorry, you need to Log In to post a reply to this thread.