Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum class factortype { num , // FACTYPE: indicate if the factor is numerical
- litteral }; // or is unknown ( symbolical )
- struct factor // FACTOR: rappresentation of an object that is part of a monomial expression
- { // a monomial expression like ⅔x will be rappresented as:
- std::variant // [ num = 2 ; power = 1 ] [ num = 3 ; power = -1 ] [ letter = x ; power = 1 ]
- < //
- std::string, //
- double //
- > //
- value; //
- factortype type; //
- double power; //
- }; //
- struct monom // MONOM: rappresentation of an object that is an entire monomial expression
- { // contains a vector of numeral factors and a vector of litteral factors
- std::vector<factor> numeral; // sign is just stored as boolean
- std::vector<factor> litteral; //
- bool sign; //
- }; //
- enum class tokentype { monomial , // TYPES: monomial expression
- operation , // an operator ( such as * - + / ^ ! )
- section , // a section delimitated by "(" and ")"
- oparen , // an opened parentesis
- cparen , // a closed parentesis
- obraket , // an opened braket for delimiting multichar name for variables
- cbraket , // a closed braket for delimiting multichar name for variables
- function , // a function name and the start of the arguments token
- comma, // the comma separeting function arguments
- endarg }; // the end of the argument token list
- enum class operation { sum, // OP: sum between two real numbers with a positive or negative sign and maybe unknow
- minus, // change sign of the following token
- mul, // moltiplication of two tokens
- div, // division of two tokens
- pow, // power of a token
- fact, // factorial of a token
- modul }; // rest of an integer division
- struct token // TOKEN: rappresentation of a self semantic unit of an expression, just as
- { // '2x' or '+' or whatelse
- std::variant // sequence of tokens can be evaluated to get a result
- < //
- monom, //
- operation, //
- std::vector<token>, //
- std::string //
- > //
- data; //
- tokentype type; //
- }; //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement