package Ġcom . dr j coding . p low . parser . parse _ functions . expression _ parse _ functions Ċ Ċ import Ġcom . dr j coding . p low . lexer . Lex Token Stream Ċ import Ġcom . dr j coding . p low . lexer . Lex TokenType Ċ import Ġcom . dr j coding . p low . parser . cst _ nodes . expression _ C ST _ nodes . Cast C ST Node Ċ import Ġcom . dr j coding . p low . parser . cst _ nodes . expression _ C ST _ nodes . Expression C ST Node Ċ import Ġcom . dr j coding . p low . parser . cst _ nodes . expression _ C ST _ nodes . Type check C ST Node Ċ import Ġcom . dr j coding . p low . parser . parse _ functions . errors . Expected TypeError Ċ import Ġcom . dr j coding . p low . parser . parse _ functions . errors . Parse Assertion Unexpected Token Ċ import Ġcom . dr j coding . p low . parser . parse _ functions . pop N ST o ken C ST Node Ċ Ċ /** Ċ Ġ* ĠParses Ġa Ġcast Ġor Ġtype check Ġassuming Ġwe Ġknow Ġone Ġexists Ġ( i . e . Ġ` foo Ġas Ġbar ` Ġor Ġ` foo Ġis Ġbar `) Ċ Ġ*/ Ċ fun Ġparse Cast Or Type check ( ts : ĠLex Token Stream , Ġto Check : ĠExpression C ST Node ): ĠExpression C ST Node Ġ{ ĊĠĠĠ Ġval Ġas Or Is Ġ= Ġts . pop N ST o ken C ST Node () ĊĠĠĠ Ġval Ġtype Ġ= Ġparse Type ( ts ) Ġ?: Ġthrow ĠExpected TypeError ( as Or Is ) ĊĊĠĠĠ Ġreturn Ġwhen Ġ( as Or Is . token . type ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLex TokenType . IS Ġ-> ĠType check C ST Node ( to Check , Ġas Or Is , Ġtype ) ĊĠĠĠĠĠĠĠ ĠLex TokenType . AS Ġ-> ĠCast C ST Node ( to Check , Ġas Or Is , Ġtype ) ĊĠĠĠĠĠĠĠ Ġelse Ġ-> Ġthrow ĠParse Assertion Unexpected Token ( ts . pop N ST o ken C ST Node (), ĠlistOf ( Lex TokenType . AS , ĠLex TokenType . IS )) ĊĠĠĠ Ġ} Ċ }