| | |
| | | // 'if' |
| | | auto ifToken = expect(Lexer::Tokens::Type::KEYWORD, "if"); |
| | | expect(Lexer::Tokens::Type::PUNCTUATION, "("); |
| | | auto condExpr = parseParsedExpression(Symbols::Variables::Type::BOOLEAN); |
| | | // Parse the condition expression without restricting literal types, |
| | | // dynamic evaluation will enforce boolean type at runtime |
| | | auto condExpr = parseParsedExpression(Symbols::Variables::Type::NULL_TYPE); |
| | | expect(Lexer::Tokens::Type::PUNCTUATION, ")"); |
| | | expect(Lexer::Tokens::Type::PUNCTUATION, "{"); |
| | | // then branch |
| | |
| | | |
| | | printnl("Child1 old age: ",$person2->children->age); |
| | | $person2->children->age = $person2->children->age + 2; |
| | | printnl("Child1 new age: ",$person2->children->age); |
| | | printnl("Child1 new age: ",$person2->children->age); |
| | | |
| | | int $age = 10; |
| | | if ($person2->children->age > 18) { |
| | | printnl("Child1 is old enough to go to school."); |
| | | } else { |
| | | printnl("Child1 is too young to go to school."); |
| | | } |