|
| 1 | +export enum NodeType { |
| 2 | + Identifer = "Identifier", |
| 3 | + VariableReference = "VariableReference", |
| 4 | + MessageReference = "MessageReference", |
| 5 | + SelectExpression = "SelectExpression", |
| 6 | + TextElement = "TextElement", |
| 7 | + Placeable = "Placeable", |
| 8 | + Variant = "Variant", |
| 9 | + Pattern = "Pattern", |
| 10 | + Message = "Message", |
| 11 | + Attribute = "Attribute", |
| 12 | + GroupComment = "GroupComment", |
| 13 | + Resource = "Resource", |
| 14 | +} |
| 15 | + |
| 16 | +export interface SyntaxNode { |
| 17 | + readonly type: NodeType; |
| 18 | +} |
| 19 | + |
| 20 | +export interface Identifier extends SyntaxNode { |
| 21 | + readonly type: NodeType.Identifer; |
| 22 | + readonly name: string; |
| 23 | +} |
| 24 | + |
| 25 | +export interface VariableReference extends SyntaxNode { |
| 26 | + readonly type: NodeType.VariableReference; |
| 27 | + readonly id: Identifier; |
| 28 | +} |
| 29 | + |
| 30 | +export interface MessageReference extends SyntaxNode { |
| 31 | + readonly type: NodeType.MessageReference; |
| 32 | + readonly id: Identifier; |
| 33 | + readonly attribute: Identifier | null; |
| 34 | +} |
| 35 | + |
| 36 | +export interface SelectExpression extends SyntaxNode { |
| 37 | + readonly type: NodeType.SelectExpression; |
| 38 | + readonly selector: InlineExpression; |
| 39 | + readonly variants: Array<Variant>; |
| 40 | +} |
| 41 | + |
| 42 | +export type InlineExpression = VariableReference | MessageReference; |
| 43 | + |
| 44 | +export type Expression = InlineExpression | SelectExpression; |
| 45 | + |
| 46 | +export interface TextElement extends SyntaxNode { |
| 47 | + readonly type: NodeType.TextElement; |
| 48 | + readonly value: string; |
| 49 | +} |
| 50 | + |
| 51 | +export interface Placeable extends SyntaxNode { |
| 52 | + readonly type: NodeType.Placeable; |
| 53 | + readonly expression: Expression; |
| 54 | +} |
| 55 | + |
| 56 | +export type PatternElement = TextElement | Placeable; |
| 57 | + |
| 58 | +export interface Variant extends SyntaxNode { |
| 59 | + readonly type: NodeType.Variant; |
| 60 | + readonly key: Identifier; |
| 61 | + readonly value: Pattern; |
| 62 | + readonly default: boolean; |
| 63 | +} |
| 64 | + |
| 65 | +export interface Pattern extends SyntaxNode { |
| 66 | + readonly type: NodeType.Pattern; |
| 67 | + readonly elements: Array<PatternElement>; |
| 68 | +} |
| 69 | + |
| 70 | +export interface Message extends SyntaxNode { |
| 71 | + readonly type: NodeType.Message; |
| 72 | + readonly id: Identifier; |
| 73 | + readonly value: Pattern | null; |
| 74 | + readonly attributes: Array<Attribute>; |
| 75 | +} |
| 76 | + |
| 77 | +export interface Attribute extends SyntaxNode { |
| 78 | + readonly type: NodeType.Attribute; |
| 79 | + readonly id: Identifier; |
| 80 | + readonly value: Pattern; |
| 81 | +} |
| 82 | + |
| 83 | +export interface GroupComment extends SyntaxNode { |
| 84 | + readonly type: NodeType.GroupComment; |
| 85 | + readonly content: string; |
| 86 | +} |
| 87 | + |
| 88 | +export type Entry = Message | GroupComment; |
| 89 | + |
| 90 | +export interface Resource extends SyntaxNode { |
| 91 | + readonly type: NodeType.Resource; |
| 92 | + readonly body: Array<Entry>; |
| 93 | +} |
0 commit comments