Doszedł do mnie taki oto kawałek: `
>>> 0x0 +2
4
>>> 0x0 +3.5
6.5
>>> 0x0 +2e1
757
` Zagadka za 0 punktów: co to za język programowania? :>
Przyszło od razu z wyjaśnieniem:
once their lexer detects "0x", it skips all '0's, then calls strtol()
so: tokptr = "0x0 +2;", toklen = 3
skip 0x: tokptr = "0 +2;", toklen = 1
skip all '0's: tokptr = " +2;", toklen = 0
call strtol(" +2", NULL, 16) ==> 2
then it proceeds to parse the remaining program starting from " +2;"
because that's where the previous token ends
and this is how 0x0 ends up having the value 2
0x0 +2e1 ends up being 757 because the first pass interprets 2e1 as a
hex integer
while the second pass thinks it's a floating point number
so it's really 0x2e1 + 2.0e1
Źródło: strona domowa internetów.
Komentarze
- Stanisław ‘dozzie’ Klekot (2012-12-05 17:49:02): Holy fscking bubbles! To nawet ja takich baboli nie wstawiłem w swoich parserach, a za eksperta się nie uważam O_o Ale trzeba być naprawdę głupim żeby tak spaprać tokenizer pisany we fleksie.
- mt3o (2012-12-05 18:17:57): PHP. Było na roflcopter.
- pecet (2012-12-05 18:59:44): PHP. Było na roflcopter.
- Shelly (2014-09-02 12:59:51): My programmer is trying to persuade me to move to .net from PHP. I have always disliked the idea because of the costs. But he’s tryiong none the less. I’ve been using WordPress on various websites for about a year and am concerned about switching to another platform. I have heard excellent things about blogengine.net. Is there a way I can transfer all my wordpress posts into it? Any kind of help would be really appreciated!