[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

do you have to use flags when parsing a programming language?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 18
Thread images: 2

do you have to use flags when parsing a programming language?
I guess you do
>//currently, no ability to differentiate between "var = -7" & "var = 7 - 7" without flags.
>>
What the fuck are you on about? What flags?
>>
what?
-7 is -7
7 - 7 is 0
>>
>>62268460
i'm talking about when parsing...

-7 is a value
7 - 7 the minus is an operator.

I'm trying to generalize a programming language.
>>
>>62268480
right now the only way to generalize the information correctly is to use a flag that's triggered after a variable name is followed by an equals signs.
the flag.
The first minus sign, would be associated with a number.
And I would want to store that number as a generalization.
>>
>>62268480
they are both values

7 + (-7)

when you assign a variable to two or more values they are added together
>>
>>62268517
so when two numeric "value" objects are next to each other they are by default summed?

if i go this route my array of memory would look like this.
[variable][equals symbol][number][number]


but then what about multiply and divide?
operators?

I may have to explain my approach a bit more.
>>
>>62268753
son, stop.

the gcc parser has 20.000 lines of code... i dont want you to end like that autistic guy with his compiler and OS
>>
>>62269741
I want to be better than terry.
>>
>>62269891
a minus character infront of a variable and a minus character infront of a number....

these are different the way they are parsed.

var = 7 - var2
var = var2 - 7

damn
>>
>>62268429
just look how it's done in craftinginterpreters

[spoiler]One is an unary operator, the other is a binary operator.[/spoiler]
>>
>>62270424
holy shit. I'm a fucking lone autist... what the fuck is a craftinig interpreter and how can I make friends online?
>>
>>62270485
craftinginterpreters.com is a (yet to be finished) online book about interpreters.
Also kek
>>
i recently just realized that with my approach I should just be concerned about the string of numbers and not necessarily about catching the negative symbol or the decimal.

lots of theorizing that's gone on about linguistics and parsing signals and stuff...

at first i wanted to make a general parser, but then i had to get focused on the task at hand.
with a general parser I could probably get a good idea about the hiearchy of information
>>
>>62268480
>-7 is a value
> 7 - 7 the minus is an operator.
You dumb mother fucker. Learn to math
>>
>>62274865
>>62268480
Unless there are 2 operators you can treat every single - sign as an operator.
>>
>>62268429
You're very near "not even wrong" territory. Drop what you're doing and grab a good book on parsing and compiler design (I recommend the dragon book by Aho, Sethi and Ullman, which no doubt dates me but is available cheap as a used book)
>>
>>62268480

Okay you fuck, you misunderstand how numbers are parsed.

In a recursive descent parser, in the deep-most layer or so, you accept a - token, and expect a number afterwards. That's how you parse a "-7". In the layer that handles addition and subtraction, you expect an expression of a deeper layer, then accept a -, then expect an expression.

Accept/expect are parser terms.
Thread posts: 18
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.