mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Big TODO for complex number parsing
This commit is contained in:
parent
3c467516c3
commit
4c852b5d39
1 changed files with 18 additions and 1 deletions
19
runtime.c
19
runtime.c
|
@ -6112,6 +6112,17 @@ int _read_is_numeric(const char *tok)
|
|||
((len > 1) && (tok[1] == '.' || isdigit(tok[1])) && (tok[0] == '-' || tok[0] == '+'))));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine if given string is a complex number
|
||||
*/
|
||||
int _read_is_complex_number(const char *tok)
|
||||
{
|
||||
int len = strlen(tok);
|
||||
// Assumption: tok already passed checks from _read_is_numeric
|
||||
return (tok[len - 1] == 'i' ||
|
||||
tok[len - 1] == 'I');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Helper function, determine if given number is a hex digit
|
||||
* @param c Character to check
|
||||
|
@ -6498,7 +6509,13 @@ void _read_return_atom(void *data, object cont, port_type *p)
|
|||
make_string(str, p->tok_buf);
|
||||
str.num_cp = Cyc_utf8_count_code_points((uint8_t *)(p->tok_buf));
|
||||
make_c_opaque(opq, &str);
|
||||
return_thread_runnable(data, &opq);
|
||||
if (_read_is_complex_number(p->tok_buf)) { // TODO: hopefully not much performance impact from this check
|
||||
TODO: return complex num, see _read_return_number for possible template
|
||||
probably want to have that function extract/identify the real/imaginary components.
|
||||
can just scan the buffer and read out start/end index of each number.
|
||||
} else {
|
||||
return_thread_runnable(data, &opq);
|
||||
}
|
||||
} else if (strncmp("+inf.0", p->tok_buf, 6) == 0 ||
|
||||
strncmp("-inf.0", p->tok_buf, 6) == 0) {
|
||||
make_double(d, pow(2.0, 1000000));
|
||||
|
|
Loading…
Add table
Reference in a new issue