int hasError(char* eq) { // TODO: Check for correctness ERROR = 0; float old_ans = ans; parse_eq(eq); ans = old_ans; return ERROR; }
STRPTR parse_strarg( INFILE *inpf ) { HSCVAR var; STRPTR strarg = NULL; if ( parse_eq( inpf) ) strarg = eval_expression( &var, inpf, NULL ); return( strarg ); }
/* ** parse_strarg */ STRPTR parse_strarg( INFILE *inpf ) { HSCVAR var; STRPTR strarg = NULL; if ( parse_eq( inpf) ) strarg = parse_vararg( &var, inpf ); return( strarg ); }
bool xml_istream::parse_empty_tag(const string& s, string& open, map<string, string>& attributes) { bool ok = false; open.clear(); attributes.clear(); size_t length = s.length(); size_t k = s.rfind("/>"); assert(s.find('<') == 0 && (k + 2) == length); size_t i = 1; if (parse_name(s, i, open) != false) { ok = true; parse_ws(s, i); while (i < k && ok != false) { string attribute, value; ok = false; if (parse_name(s, i, attribute) != false) { if (parse_eq(s, i) != false) { char ch = s[i]; if (ch == '\'' || ch == '"') { ++i; for (; i < k && s[i] != ch; ++i) { value += s[i]; } if (s[i] == ch) { attributes[attribute] = value; ok = true; } } } } ++i; parse_ws(s, i); } } return ok; }
float evaluate(char* eq) { // TODO: Check for correctness parse_eq(eq); if (ERROR) { // notify of syntax error (maybe error codes?) return 0; } if (curr_eq) free(curr_eq); curr_eq = eq; return ans; }
/* ** parse_tag_option */ static BOOL parse_tag_option( HSCPRC *hp, STRPTR option, HSCTAG *tag ) { BOOL ok = FALSE; HSCATTR *attr = new_hscattr( SPECIAL_FILE_ID "MBI+NAW" ); attr->vartype = VT_STRING; if ( !(upstrcmp(option,TO_MBI_STR) && upstrcmp(option,TO_MBI_SHT) ) ) { /* must be inside */ if ( parse_eq( hp ) ) { STRPTR strmbi = eval_expression( hp, attr, NULL ); if ( strmbi ) { tag->mbi = strclone( strmbi ); DDT( fprintf( stderr, DHL " mbi = `%s'\n", tag->mbi ) ); ok = TRUE; } } } else if ( !( upstrcmp( option, TO_NAW_STR ) && upstrcmp(option,TO_NAW_SHT) ) ) { /* not allowed with */ if ( parse_eq( hp ) ) { STRPTR strnaw = eval_expression( hp, attr, NULL ); if ( strnaw ) { tag->naw = strclone( strnaw ); DDT( fprintf( stderr, DHL " mbi = `%s'\n", tag->naw ) ); ok = TRUE; } } } else if ( !( upstrcmp( option, TO_LAZY_STR ) && upstrcmp(option,TO_LAZY_SHT) ) ) { /* lazy standard attribs */ if ( parse_eq( hp ) ) { STRPTR strlazy = eval_expression( hp, attr, NULL ); if ( strlazy ) { DDT( fprintf( stderr, DHL " lazy= `%s'\n", strlazy ) ); ok = parse_lazy_option( hp, tag, strlazy ); } } } else { ok |= check_tag_option( hp, option, tag, TO_CLOSE_STR, TO_CLOSE_SHT, HT_CLOSE ); ok |= check_tag_option( hp, option, tag, TO_SPECIAL_STR, TO_SPECIAL_SHT, HT_SPECIAL ); ok |= check_tag_option( hp, option, tag, TO_JERK_STR, TO_JERK_SHT, HT_JERK ); ok |= check_tag_option( hp, option, tag, TO_AUTOCLOSE_STR, TO_AUTOCLOSE_SHT, HT_AUTOCLOSE ); ok |= check_tag_option( hp, option, tag, TO_OBSOLETE_STR, TO_OBSOLETE_SHT, HT_OBSOLETE ); ok |= check_tag_option( hp, option, tag, TO_ONLYONCE_STR, TO_ONLYONCE_SHT, HT_ONLYONCE ); ok |= check_tag_option( hp, option, tag, TO_REQUIRED_STR, TO_REQUIRED_SHT, HT_REQUIRED ); ok |= check_tag_option( hp, option, tag, TO_SKIPLF_STR, TO_SKIPLF_SHT, HT_SKIPLF ); if ( !ok ) { hsc_message( hp, MSG_UNKN_TAG_OPTION, "unknown tag option %q", option ); } } /* remove temp. attribute */ del_hscattr( attr ); return( ok ); }