get rid of all those Comments
This commit is contained in:
parent
653ff5df10
commit
146d2a22ee
|
|
@ -657,7 +657,7 @@ export class Compiler {
|
|||
}
|
||||
|
||||
case terms.Array: {
|
||||
const children = getAllChildren(node).filter((n) => n.type.id !== terms.Comment)
|
||||
const children = getAllChildren(node)
|
||||
|
||||
// We can easily parse [=] as an empty dict, but `[ = ]` is tougher.
|
||||
// = can be a valid word, and is also valid inside words, so for now we cheat
|
||||
|
|
@ -676,7 +676,7 @@ export class Compiler {
|
|||
}
|
||||
|
||||
case terms.Dict: {
|
||||
const children = getAllChildren(node).filter((n) => n.type.id !== terms.Comment)
|
||||
const children = getAllChildren(node)
|
||||
const instructions: ProgramItem[] = []
|
||||
|
||||
children.forEach((node) => {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ export const getAllChildren = (node: SyntaxNode): SyntaxNode[] => {
|
|||
children.push(child)
|
||||
child = child.nextSibling
|
||||
}
|
||||
return children
|
||||
|
||||
return children.filter((n) => n.type.id !== terms.Comment)
|
||||
}
|
||||
|
||||
export const getBinaryParts = (node: SyntaxNode) => {
|
||||
|
|
@ -50,13 +51,15 @@ export const getAssignmentParts = (node: SyntaxNode) => {
|
|||
|
||||
// array destructuring
|
||||
if (left && left.type.id === terms.Array) {
|
||||
const identifiers = getAllChildren(left).filter(child => child.type.id === terms.Identifier)
|
||||
const identifiers = getAllChildren(left).filter((child) => child.type.id === terms.Identifier)
|
||||
return { arrayPattern: identifiers, right }
|
||||
}
|
||||
|
||||
if (!left || left.type.id !== terms.AssignableIdentifier) {
|
||||
throw new CompilerError(
|
||||
`Assign left child must be an AssignableIdentifier or Array, got ${left ? left.type.name : 'none'}`,
|
||||
`Assign left child must be an AssignableIdentifier or Array, got ${
|
||||
left ? left.type.name : 'none'
|
||||
}`,
|
||||
node.from,
|
||||
node.to
|
||||
)
|
||||
|
|
@ -71,7 +74,9 @@ export const getCompoundAssignmentParts = (node: SyntaxNode) => {
|
|||
|
||||
if (!left || left.type.id !== terms.AssignableIdentifier) {
|
||||
throw new CompilerError(
|
||||
`CompoundAssign left child must be an AssignableIdentifier, got ${left ? left.type.name : 'none'}`,
|
||||
`CompoundAssign left child must be an AssignableIdentifier, got ${
|
||||
left ? left.type.name : 'none'
|
||||
}`,
|
||||
node.from,
|
||||
node.to
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user