Appearance
| 1 | namespace Syntax.Trees.Pragmas is | |
| 2 | use Source; | |
| 3 | ||
| 4 | // A `name = value` argument of an attribute pragma. Unlike a positional | |
| 5 | // argument it is not a visitable AST node — only its value expression is | |
| 6 | // walked (so it gets compiled); the name is resolved against the | |
| 7 | // attribute type's members by ATTRIBUTE_RESOLVER, not as a scope use. | |
| 8 | class NAMED_ARGUMENT(name: Identifiers.Identifier, value: Expressions.Expression) is | |
| 9 | si | |
| 10 | ||
| 11 | class PRAGMA( | |
| 12 | location: LOCATION, | |
| 13 | name: Identifiers.Identifier, | |
| 14 | arguments: Expressions.LIST, | |
| 15 | named_arguments: Collections.LIST[NAMED_ARGUMENT]? | |
| 16 | ): Trees.Node is | |
| 17 | super(location); | |
| 18 | ||
| 19 | is_name_equal_to(other_name: string) -> bool => other_name =~ name.name; | |
| 20 | ||
| 21 | try_get_string_literal_at(index: int) -> string? => | |
| 22 | arguments.try_get_string_literal_at(index); | |
| 23 | ||
| 24 | ||
| 25 | accept(visitor: Visitor) is | |
| 26 | visitor.visit(self); | |
| 27 | si | |
| 28 | ||
| 29 | walk(visitor: Visitor) is | |
| 30 | if !visitor.pre(self) then | |
| 31 | name.walk(visitor); | |
| 32 | ||
| 33 | arguments.walk(visitor); | |
| 34 | ||
| 35 | if named_arguments? then | |
| 36 | for named_argument in named_arguments do | |
| 37 | named_argument.value.walk(visitor); | |
| 38 | od | |
| 39 | fi | |
| 40 | fi | |
| 41 | ||
| 42 | accept(visitor); | |
| 43 | si | |
| 44 | si | |
| 45 | si |