fix: braced property access

This commit is contained in:
wyozi
2020-10-09 21:18:40 +08:00
committed by Jun Yang
parent a6126c3bea
commit 18a807ea2e
4 changed files with 24 additions and 2 deletions
+10 -1
View File
@@ -2,13 +2,22 @@ import { Token } from './token'
import { WordToken } from './word-token'
import { QuotedToken } from './quoted-token'
import { TokenKind } from '../parser/token-kind'
import { parseStringLiteral } from '../parser/parse-string-literal'
export class PropertyAccessToken extends Token {
constructor (
public variable: WordToken,
public variable: WordToken | QuotedToken,
public props: (WordToken | QuotedToken | PropertyAccessToken)[],
end: number
) {
super(TokenKind.PropertyAccess, variable.input, variable.begin, end, variable.file)
}
getVariableAsText() {
if (this.variable instanceof WordToken) {
return this.variable.getText()
} else {
return parseStringLiteral(this.variable.getText())
}
}
}