lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> If we have to be able to put the read pointer back where it was before
> the read in case the character is invalid (e.g. so a different
> function could read out the raw bytes) then that couldn't be done with
> a single unget.

The reading of numbers already poses a similar problem, and Lua solves
it the simple way. From the manual:

  "n": reads a numeral and returns it as a float or an integer,
  following the lexical conventions of Lua. (The numeral may have leading
  spaces and a sign.)  This format always reads the longest input sequence
  that is a valid prefix for a numeral; if that prefix does not form a
  valid numeral (e.g., an empty string, "0x", or "3.4e-"), it is discarded
  and the function returns nil.

-- Roberto