A snippet of the source text Can be strings, whitespace or comments
| 14 | // A snippet of the source text |
| 15 | // Can be strings, whitespace or comments |
| 16 | struct DefSyntaxToken |
| 17 | { |
| 18 | enum class Type |
| 19 | { |
| 20 | Nothing, |
| 21 | Whitespace, |
| 22 | BracedBlock, // starting with { and *maybe* ending with } |
| 23 | Token, |
| 24 | EolComment, |
| 25 | BlockComment, |
| 26 | }; |
| 27 | |
| 28 | // Token type |
| 29 | Type type; |
| 30 | |
| 31 | // The raw string as parsed from the source text |
| 32 | std::string value; |
| 33 | |
| 34 | DefSyntaxToken() : |
| 35 | DefSyntaxToken(Type::Nothing, "") |
| 36 | {} |
| 37 | |
| 38 | DefSyntaxToken(Type type_, const std::string& value_) : |
| 39 | type(type_), |
| 40 | value(value_) |
| 41 | {} |
| 42 | |
| 43 | void clear() |
| 44 | { |
| 45 | type = Type::Nothing; |
| 46 | value.clear(); |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | // Represents an element of a parsed syntax tree. |
| 51 | // Each node can have 0 or more child nodes, grouping them |