Timeline for Desired pattern for expression parsing into RPN
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 31, 2017 at 9:20 | comment | added | amon |
@downrep_nation Yes you can treat = as an expression level operator. There are some languages that do this, and later check whether the left side is a legal assignment target (e.g. Perl). In some languages, the = is both an assignment operator and part of the variable declaration statement syntax (e.g. C, C#, Java). In other languages like Python, the = is a fixed part of the assignment statement syntax, and not a legal operator inside expressions. So this depends entirely on the language you are implementing.
|
|
Aug 31, 2017 at 6:12 | comment | added | downrep_nation | so i could theoretically treat = as an operator? | |
Aug 31, 2017 at 5:37 | comment | added | amon |
@downrep_nation Yes, absolutely correct. There are some expressions to which we can assign, sometimes called Lvalues. In general we write a separate grammar rule for Lvalues and Rvalues. In practice, there often is some rule in the ordinary expression syntax that already describes legal Lvalues. Note that in C# the parser can't know whether syntax like x.Foo is an Lvalue because the Foo might be a read-only property. That decision is left to a later phase (semantic analysis/ type checking).
|
|
Aug 31, 2017 at 4:12 | comment | added | downrep_nation | Great insight, Indeed i use recursive descent to parse my language. Only one question , isnt dictionary["foo"] = 5-3; an expression where the left side is an expression too? | |
Aug 31, 2017 at 4:10 | vote | accept | downrep_nation | ||
Aug 30, 2017 at 21:37 | history | answered | amon | CC BY-SA 3.0 |