template <typename R> bool extract_word(R& result,tokenizer& tokenizer) { result.clear(); //buffer array<ascii> buffer; //word if(!tokenizer.word(buffer)) return false; //delimited if(!tokenizer.is_delimited()) return false; //commit result=buffer; update(symbols()._word,buffer); return true; }
template <typename R> bool extract_identifier(R& result,tokenizer& tokenizer) { result.clear(); //buffer array<ascii> buffer; array<ascii> current; //identifier if(!tokenizer.identifier(current)) return false; buffer.append(current); //word if(tokenizer.word(current)) buffer.append(current); //delimited if(!tokenizer.is_delimited()) return false; //commit result=buffer; update(symbols()._identifier,buffer); return true; }
template <typename R> bool extract_number(R& result,tokenizer& tokenizer) { result.clear(); //buffer array<ascii> buffer; array<ascii> current; //sign if(tokenizer.any(current,pack("+","-"))) buffer.append(current); //integer part if(tokenizer.digit(current)) buffer.append(current); //real part if(tokenizer.delimit(current,".")) { buffer.append(current); if(tokenizer.digit(current)) buffer.append(current); } //parse with c api if(!buffer.join("").is_real()) return false; //no dot after if(tokenizer.starts_with(".")) return false; //delimited if(!tokenizer.is_delimited()) return false; //commit result=buffer; update(symbols()._number,buffer); return true; }