* Fully expand the given macro name and return the resulting list of * tokens, or return `undefined` if no such macro is defined.
(name)
| 14080 | |
| 14081 | |
| 14082 | expandMacro(name) { |
| 14083 | if (!this.macros.get(name)) { |
| 14084 | return undefined; |
| 14085 | } |
| 14086 | |
| 14087 | const output = []; |
| 14088 | const oldStackLength = this.stack.length; |
| 14089 | this.pushToken(new Token(name)); |
| 14090 | |
| 14091 | while (this.stack.length > oldStackLength) { |
| 14092 | const expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded. |
| 14093 | |
| 14094 | if (expanded instanceof Token) { |
| 14095 | output.push(this.stack.pop()); |
| 14096 | } |
| 14097 | } |
| 14098 | |
| 14099 | return output; |
| 14100 | } |
| 14101 | /** |
| 14102 | * Fully expand the given macro name and return the result as a string, |
| 14103 | * or return `undefined` if no such macro is defined. |
no test coverage detected