import Scanner from '../scanner' ; import { ENDVariableStatement , ENDVariable , ParsedTag , ENDAttribute } from '../ast' ; import { emptyBody } from '../tag' ; import { isIdentifier } from '../utils' ; import { ENDCompileError } from '../syntax-error' ; param scanner param openTag export default function variableStatement ( scanner , openTag ) { emptyBody ( scanner , openTag ) ; return { type : 'ENDVariableStatement' , start : openTag . start , end : openTag . end , variables : openTag . attributes . map ( attrToVariable ) , loc : openTag . loc } ; } function attrToVariable ( attr ) { if ( ! isIdentifier ( attr . name ) ) { throw new ENDCompileError ( `Expecting identifier as variable name` , attr . name ) ; } return { type : 'ENDVariable' , start : attr . start , end : attr . end , name : attr . name . name , value : attr . value , loc : attr . loc } ; }