def get(O): fss = O.fss code = fss.code stop = len(code) assert O.i is not None def raise_invalid(): fss.raise_error(msg="Invalid FORMAT specification", i=min(stop-1, O.i)) while (O.i < stop): i_code = O.i c = code[i_code] if (c == ","): O.i += 1 continue if (c == "x"): O.i += 1 return tk_format(ssl=fss, i_code=i_code, value="1x") if ("():/$".find(c) >= 0): O.i += 1 return tk_op(ssl=fss, i_code=i_code, value=c) if (c == "'"): O.i += 1 return tk_string( ssl=fss, i_code=i_code, value=fss.strings[fss.string_indices.index(i_code)]) if (c == "+" or c == "-"): j = unsigned_integer_scan(code=code, start=i_code+1, stop=stop) if (j < 0 or not code.startswith("p", j)): raise_invalid() O.i = j + 1 return tk_format( ssl=fss, i_code=i_code, value=code[i_code:O.i]) j = unsigned_integer_scan(code=code, start=i_code, stop=stop) if (j > 0): O.i = j if (code.startswith("h", O.i)): # extract Hollerith edit descriptor if it did not confuse the # previous ignorant parsing algorithms sl, i_text = fss.text_location(i=O.i) assert sl.text[i_text].lower() == "h" i_text += 1 nh = int(code[i_code:j]) j_text = i_text + nh tv = sl.text[i_text:j_text] if (len(tv) != nh): raise RuntimeError(fss.format_error( i=i_code, msg="FATAL: Not supported: FORMAT Hollerith edit descriptor" " spanning continuation lines")) if (tv.find("'") >= 0 or tv.find('"') >= 0): raise RuntimeError(fss.format_error( i=i_code, msg="FATAL: Not supported:" " FORMAT Hollerith edit descriptor with quotes")) while (O.i < stop): sl, i_text = fss.text_location(i=O.i) if (i_text >= j_text): break O.i += 1 return tk_string(ssl=fss, i_code=i_code, value=tv) if (code.startswith("x", O.i) or code.startswith("p", O.i)): O.i += 1 return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) return tk_integer(ssl=fss, i_code=i_code, value=code[i_code:j]) if ("defgiz".find(c) >= 0): j = unsigned_integer_scan(code=code, start=i_code+1, stop=stop) if (j > 0): O.i = j if (code.startswith(".", j)): j = unsigned_integer_scan(code=code, start=j+1, stop=stop) if (j < 0): raise_invalid() O.i = j return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) if (c == "a" or c == "l"): O.i += 1 j = unsigned_integer_scan(code=code, start=i_code+1, stop=stop) if (j > 0): O.i = j return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) if (code.startswith("bn", i_code) or code.startswith("bz", i_code)): O.i += 2 return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) if (c == "s"): O.i += 1 if (code.startswith("p", O.i) or code.startswith("s", O.i)): O.i += 1 return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) if (c == "t"): O.i += 1 if (code.startswith("l", O.i) or code.startswith("r", O.i)): O.i += 1 j = unsigned_integer_scan(code=code, start=O.i, stop=stop) if (j < 0): raise_invalid() O.i = j return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) raise_invalid() O.i = None return None
def get(O): fss = O.fss code = fss.code stop = len(code) assert O.i is not None def raise_invalid(): fss.raise_error(msg="Invalid FORMAT specification", i=min(stop - 1, O.i)) while (O.i < stop): i_code = O.i c = code[i_code] if (c == ","): O.i += 1 continue if (c == "x"): O.i += 1 return tk_format(ssl=fss, i_code=i_code, value="1x") if ("():/$".find(c) >= 0): O.i += 1 return tk_op(ssl=fss, i_code=i_code, value=c) if (c == "'"): O.i += 1 return tk_string( ssl=fss, i_code=i_code, value=fss.strings[fss.string_indices.index(i_code)]) if (c == "+" or c == "-"): j = unsigned_integer_scan(code=code, start=i_code + 1, stop=stop) if (j < 0 or not code.startswith("p", j)): raise_invalid() O.i = j + 1 return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) j = unsigned_integer_scan(code=code, start=i_code, stop=stop) if (j > 0): O.i = j if (code.startswith("h", O.i)): # extract Hollerith edit descriptor if it did not confuse the # previous ignorant parsing algorithms sl, i_text = fss.text_location(i=O.i) assert sl.text[i_text].lower() == "h" i_text += 1 nh = int(code[i_code:j]) j_text = i_text + nh tv = sl.text[i_text:j_text] if (len(tv) != nh): raise RuntimeError( fss.format_error( i=i_code, msg= "FATAL: Not supported: FORMAT Hollerith edit descriptor" " spanning continuation lines")) if (tv.find("'") >= 0 or tv.find('"') >= 0): raise RuntimeError( fss.format_error( i=i_code, msg="FATAL: Not supported:" " FORMAT Hollerith edit descriptor with quotes" )) while (O.i < stop): sl, i_text = fss.text_location(i=O.i) if (i_text >= j_text): break O.i += 1 return tk_string(ssl=fss, i_code=i_code, value=tv) if (code.startswith("x", O.i) or code.startswith("p", O.i)): O.i += 1 return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) return tk_integer(ssl=fss, i_code=i_code, value=code[i_code:j]) if ("defgiz".find(c) >= 0): j = unsigned_integer_scan(code=code, start=i_code + 1, stop=stop) if (j > 0): O.i = j if (code.startswith(".", j)): j = unsigned_integer_scan(code=code, start=j + 1, stop=stop) if (j < 0): raise_invalid() O.i = j return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) if (c == "a" or c == "l"): O.i += 1 j = unsigned_integer_scan(code=code, start=i_code + 1, stop=stop) if (j > 0): O.i = j return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) if (code.startswith("bn", i_code) or code.startswith("bz", i_code)): O.i += 2 return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) if (c == "s"): O.i += 1 if (code.startswith("p", O.i) or code.startswith("s", O.i)): O.i += 1 return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) if (c == "t"): O.i += 1 if (code.startswith("l", O.i) or code.startswith("r", O.i)): O.i += 1 j = unsigned_integer_scan(code=code, start=O.i, stop=stop) if (j < 0): raise_invalid() O.i = j return tk_format(ssl=fss, i_code=i_code, value=code[i_code:O.i]) raise_invalid() O.i = None return None
def get(O, optional=False): ssl = O.ssl code = ssl.code stop = O.stop def return_none(): if (not optional): if (stop == 0): ssl.raise_syntax_error() else: ssl.raise_syntax_error(i=stop-1) O.i = None return None if (len(O.buffer) != 0): O.i, result = O.buffer.pop(0) if (result is None): return_none() return result if (O.i is None): if (optional): return None ssl.raise_internal_error(i=stop-1) while (O.i < stop): i_code = O.i c = code[i_code] if ("=<>".find(c) >= 0): if (code.startswith("=", i_code+1)): O.i += 2 return tk_op(ssl=ssl, i_code=i_code, value=code[i_code:i_code+2]) O.i += 1 return tk_op(ssl=ssl, i_code=i_code, value=c) if ("(),:+-".find(c) >= 0): O.i += 1 return tk_op(ssl=ssl, i_code=i_code, value=c) if (c == "'"): O.i += 1 return tk_string( ssl=ssl, i_code=i_code, value=ssl.strings[ssl.string_indices.index(i_code)]) if (c == "x" and code.startswith("'", i_code+1)): O.i += 2 return tk_hexadecimal( ssl=ssl, i_code=i_code, value=ssl.strings[ssl.string_indices.index(i_code+1)]) j = identifier_scan(code=code, start=i_code) if (j > 0): O.i = j return tk_identifier(ssl=ssl, i_code=i_code, value=code[i_code:j]) if (c == "*"): if (code.startswith("*", i_code+1)): O.i += 2 return tk_op(ssl=ssl, i_code=i_code, value="**") O.i += 1 return tk_op(ssl=ssl, i_code=i_code, value="*") if (c == "/"): if (code.startswith("/", i_code+1)): O.i += 2 return tk_op(ssl=ssl, i_code=i_code, value="//") if (code.startswith("=", i_code+1)): O.i += 2 return tk_op(ssl=ssl, i_code=i_code, value="/=") O.i += 1 return tk_op(ssl=ssl, i_code=i_code, value="/") if (c == "."): return O.__after_dot(i_fld=i_code, i_dot=i_code) j = unsigned_integer_scan(code=code, start=i_code, stop=stop) if (j > 0): if (j == stop): O.i = j return tk_integer(ssl=ssl, i_code=i_code, value=code[i_code:j]) cj = code[j] if (cj == "."): if (j + 1 == stop): O.i = stop return tk_real(ssl=ssl, i_code=i_code, value=code[i_code:stop]) return O.__after_dot(i_fld=i_code, i_dot=j) if (cj == "e" or cj == "d"): k = floating_point_scan_after_exponent_char( code=code, start=j+1, stop=stop) if (k < 0): ssl.raise_error( msg="Invalid floating-point literal", i=j+1) O.i = k if (cj == "d"): return tk_double_precision( ssl=ssl, i_code=i_code, value=code[i_code:k]) return tk_real(ssl=ssl, i_code=i_code, value=code[i_code:k]) O.i = j return tk_integer(ssl=ssl, i_code=i_code, value=code[i_code:j]) ssl.raise_syntax_error(i=i_code) return_none()
def get(O, optional=False): ssl = O.ssl code = ssl.code stop = O.stop def return_none(): if (not optional): if (stop == 0): ssl.raise_syntax_error() else: ssl.raise_syntax_error(i=stop - 1) O.i = None return None if (len(O.buffer) != 0): O.i, result = O.buffer.pop(0) if (result is None): return_none() return result if (O.i is None): if (optional): return None ssl.raise_internal_error(i=stop - 1) while (O.i < stop): i_code = O.i c = code[i_code] if ("=<>".find(c) >= 0): if (code.startswith("=", i_code + 1)): O.i += 2 return tk_op(ssl=ssl, i_code=i_code, value=code[i_code:i_code + 2]) O.i += 1 return tk_op(ssl=ssl, i_code=i_code, value=c) if ("(),:+-".find(c) >= 0): O.i += 1 return tk_op(ssl=ssl, i_code=i_code, value=c) if (c == "'"): O.i += 1 return tk_string( ssl=ssl, i_code=i_code, value=ssl.strings[ssl.string_indices.index(i_code)]) if (c == "x" and code.startswith("'", i_code + 1)): O.i += 2 return tk_hexadecimal( ssl=ssl, i_code=i_code, value=ssl.strings[ssl.string_indices.index(i_code + 1)]) j = identifier_scan(code=code, start=i_code) if (j > 0): O.i = j return tk_identifier(ssl=ssl, i_code=i_code, value=code[i_code:j]) if (c == "*"): if (code.startswith("*", i_code + 1)): O.i += 2 return tk_op(ssl=ssl, i_code=i_code, value="**") O.i += 1 return tk_op(ssl=ssl, i_code=i_code, value="*") if (c == "/"): if (code.startswith("/", i_code + 1)): O.i += 2 return tk_op(ssl=ssl, i_code=i_code, value="//") if (code.startswith("=", i_code + 1)): O.i += 2 return tk_op(ssl=ssl, i_code=i_code, value="/=") O.i += 1 return tk_op(ssl=ssl, i_code=i_code, value="/") if (c == "."): return O.__after_dot(i_fld=i_code, i_dot=i_code) j = unsigned_integer_scan(code=code, start=i_code, stop=stop) if (j > 0): if (j == stop): O.i = j return tk_integer(ssl=ssl, i_code=i_code, value=code[i_code:j]) cj = code[j] if (cj == "."): if (j + 1 == stop): O.i = stop return tk_real(ssl=ssl, i_code=i_code, value=code[i_code:stop]) return O.__after_dot(i_fld=i_code, i_dot=j) if (cj == "e" or cj == "d"): k = floating_point_scan_after_exponent_char(code=code, start=j + 1, stop=stop) if (k < 0): ssl.raise_error(msg="Invalid floating-point literal", i=j + 1) O.i = k if (cj == "d"): return tk_double_precision(ssl=ssl, i_code=i_code, value=code[i_code:k]) return tk_real(ssl=ssl, i_code=i_code, value=code[i_code:k]) O.i = j return tk_integer(ssl=ssl, i_code=i_code, value=code[i_code:j]) ssl.raise_syntax_error(i=i_code) return_none()