Question: / / Project 0 : Structs and Traits in Rust, Parsing / ASTs , S - expressions, Polish notation / / Write a parser that
Project : Structs and Traits in Rust, ParsingASTs Sexpressions, Polish notation
Write a parser that parses an Sexpression language for Polish notation and converts it into an AST using the structs defined in the lib.rs file
The language should support artihmetic operations: where arguments can be integers or other polish notation expressions
Parentheses are optional for binary operators, but are mandator in other kary instances
These are some examples of equivalent inputs:
Note that operations and are all left associative
Note that the operation is right associative
Note that and support unary arguments, whereas and do not
Parse errors: return an ErrorExp struct
eg
return ErrorExp, and cannot be used as unary operators
ditto
return ErrorExp, parens cannot go alone
return ErrorExp, operators must have or more operands in all cases
x return ErrorExp, only numeric characters, whitespace, are valid input characters
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
