Closed itsumura-h closed 3 months ago
proc identifyBlockType(str:string, point:int):BlockType = if str.substr(point, point+2) == "$if": return ifBlock elif str.substr(point, point+4) == "$elif": return elifBlock elif str.substr(point, point+4) == "$else": return elseBlock elif str.substr(point, point+3) == "$for": return forBlock elif str.substr(point, point+4) == "$case": return caseBlock elif str.substr(point, point+2) == "$of": return ofBlock elif str.substr(point, point+5) == "$while": return whileBlock elif str.substr(point, point+1) == "$(": return displayVariableBlock elif str.substr(point, point+1) == "${": return nimCodeBlock else: let strAfterDoller = str.substr(point+1, point+2) if "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".contains(strAfterDoller): raise newException(Exception, "The format of $xxx is invalid. Please specify $if, $elif, $else, $for, $case, $of, $while, $(), or ${}.") return strBlock