| 64 | } |
| 65 | |
| 66 | bool reshadefx::parser::parse_top(bool &parse_success) |
| 67 | { |
| 68 | if (accept(tokenid::pragma)) |
| 69 | { |
| 70 | if (!expect('(') || !expect(tokenid::string_literal)) |
| 71 | return false; |
| 72 | |
| 73 | _codegen->emit_pragma(_token.literal_as_string); |
| 74 | |
| 75 | if (!expect(')')) |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | if (accept(tokenid::namespace_)) |
| 80 | { |
| 81 | // Anonymous namespaces are not supported right now, so an identifier is a must |
| 82 | if (!expect(tokenid::identifier)) |
| 83 | return false; |
| 84 | |
| 85 | const std::string name = std::move(_token.literal_as_string); |
| 86 | |
| 87 | if (!expect('{')) |
| 88 | return false; |
| 89 | |
| 90 | enter_namespace(name); |
| 91 | |
| 92 | bool current_success = true; |
| 93 | bool parse_success_namespace = true; |
| 94 | |
| 95 | // Recursively parse top level statements until the namespace is closed again |
| 96 | while (!peek('}') && !peek(tokenid::end_of_file)) // Empty namespaces are valid |
| 97 | { |
| 98 | if (!parse_top(current_success)) |
| 99 | { |
| 100 | return false; |
| 101 | } |
| 102 | if (!current_success) |
| 103 | { |
| 104 | parse_success_namespace = false; |
| 105 | continue; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | leave_namespace(); |
| 110 | |
| 111 | parse_success = expect('}') && parse_success_namespace; |
| 112 | } |
| 113 | else if (accept(tokenid::struct_)) // Structure keyword found, parse the structure definition |
| 114 | { |
| 115 | // Structure definitions are terminated with a semicolon |
| 116 | parse_success = parse_struct() && expect(';'); |
| 117 | } |
| 118 | else if (accept(tokenid::technique)) // Technique keyword found, parse the technique definition |
| 119 | { |
| 120 | parse_success = parse_technique(); |
| 121 | } |
| 122 | else |
| 123 | { |
nothing calls this directly
no test coverage detected