sexp :: SExpProcessor :: defaultinit
sexp $ SExpProcessor :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
parser_base :: StringProcessor :: current_location
Gives the current location in thesrc
sexp :: SExpProcessor :: defaultinit
core :: Object :: defaultinit
parser_base :: StringProcessor :: hot_location
Returns the current location as aLocation
object
parser_base :: StringProcessor :: ignore_until
Reads characters until patterns
is found
parser_base :: StringProcessor :: ignore_until_whitespace
Ignores any printable character until a whitespace is encounteredparser_base :: StringProcessor :: ignore_until_whitespace_or_comment
Advancepos
until a whitespace or #
is encountered
parser_base :: StringProcessor :: ignore_whitespaces
Advances insrc
until a non-whitespace character is encountered
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
parser_base :: StringProcessor :: line_offset
Offset in the current lineparser_base :: StringProcessor :: line_start
Position at which current line startedparser_base :: StringProcessor :: line_start=
Position at which current line startedcore :: Object :: output_class_name
Display class name on stdout (debug only).parser_base :: StringProcessor :: read_number
Read a token and parse it as aFloat
parser_base :: StringProcessor :: read_token
Read a single token after skipping preceding whitespacesparser_base :: StringProcessor :: read_until_eol_or_comment
Advancepos
until the next end of line or a #
parser_base :: StringProcessor :: read_vec3
Read 2 or 3 numbers and return them as aVec3
parser_base :: StringProcessor :: read_vec4
Read 3 or 4 numbers and return them as aVec4
parser_base :: StringProcessor :: skip_eol
Advancepos
to skip the next end of line
parser_base :: StringProcessor
Basic facilities for common parser operations on String sources
# S-Expression processor
class SExpProcessor
super StringProcessor
# Parses an S-Expression entity
fun parse_entity: SExpEntity do
var srclen = src.length
var delims = once ['(', ')', '"']
ignore_whitespaces
if pos >= srclen then return new SExpError(new Location(line, line_offset), "Empty S-Expression")
var c = src[pos]
if c == '(' then
var cnt = new SExp
var loc = new Location(line, line_offset)
pos += 1
while pos < srclen and src[pos] != ')' do
var p = parse_entity
if p isa SExpError then break
cnt.content.add p
ignore_whitespaces
end
if pos < srclen and src[pos] == ')' then
pos += 1
return cnt
else
return new SExpError(loc, "Incomplete S-Expression")
end
else if c == '"' then
var stdq = pos
var loc = new Location(line, line_offset)
pos += 1
ignore_until("\"")
pos += 1
var endq = pos
return new SExpDQString(loc, src.substring(stdq, endq - stdq))
else
var stid = pos
var loc = new Location(line, line_offset)
while pos < srclen and not c.is_whitespace and not delims.has(c) do
c = src[pos]
pos += 1
end
if delims.has(c) or c.is_whitespace then pos -= 1
if pos >= srclen then return new SExpError(loc, "Invalid S-Expression")
var endid = pos
var cntstr = src.substring(stid, endid - stid)
var cnt: SExpEntity
if cntstr.is_numeric then
cnt = new SExpFloat(loc, cntstr.to_f)
else
cnt = new SExpId(loc, cntstr)
end
return cnt
end
end
end
lib/sexp/sexp.nit:93,1--148,3