Simple base for hand-made parsers of all kinds

Introduced classes

class Location

parser_base :: Location

Information about the location of an entity in a source document
class StringProcessor

parser_base :: StringProcessor

Basic facilities for common parser operations on String sources

Redefined classes

redef abstract class Deserializer

parser_base :: parser_base $ Deserializer

Abstract deserialization service

All class definitions

redef abstract class Deserializer

parser_base :: parser_base $ Deserializer

Abstract deserialization service
class Location

parser_base $ Location

Information about the location of an entity in a source document
class StringProcessor

parser_base $ StringProcessor

Basic facilities for common parser operations on String sources
package_diagram parser_base::parser_base parser_base serialization serialization parser_base::parser_base->serialization poset poset serialization->poset meta meta serialization->meta json json serialization->json ...poset ... ...poset->poset ...meta ... ...meta->meta ...json ... ...json->json json::error error json::error->parser_base::parser_base dom::xml_entities xml_entities dom::xml_entities->parser_base::parser_base gamnit::model_parser_base model_parser_base gamnit::model_parser_base->parser_base::parser_base sexp::sexp sexp sexp::sexp->parser_base::parser_base json::static static json::static->json::error json::static... ... json::static...->json::static dom::parser parser dom::parser->dom::xml_entities dom::parser... ... dom::parser...->dom::parser gamnit::obj obj gamnit::obj->gamnit::model_parser_base gamnit::mtl mtl gamnit::mtl->gamnit::model_parser_base gamnit::obj... ... gamnit::obj...->gamnit::obj gamnit::mtl... ... gamnit::mtl...->gamnit::mtl a_star-m a_star-m a_star-m->sexp::sexp a_star-m... ... a_star-m...->a_star-m

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module array

core :: array

This module introduces the standard array structure.
module bitset

core :: bitset

Services to handle BitSet
module bytes

core :: bytes

Services for byte streams and arrays
module caching

serialization :: caching

Services for caching serialization engines
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module engine_tools

serialization :: engine_tools

Advanced services for serialization engines
module environ

core :: environ

Access to the environment variables of the process
module error

core :: error

Standard error-management infrastructure.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module file

core :: file

File manipulations (create, read, write, etc.)
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module inspect

serialization :: inspect

Refine Serializable::inspect to show more useful information
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module kernel

core :: kernel

Most basic classes and methods.
module list

core :: list

This module handle double linked lists
module math

core :: math

Mathematical operations
module meta

meta :: meta

Simple user-defined meta-level to manipulate types of instances as object.
module native

core :: native

Native structures for text and bytes
module numeric

core :: numeric

Advanced services for Numeric types
module protocol

core :: protocol

module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module re

core :: re

Regular expression support for all services based on Pattern
module ropes

core :: ropes

Tree-based representation of a String.
module serialization_core

serialization :: serialization_core

Abstract services to serialize Nit objects to different formats
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module stream

core :: stream

Input and output streams of characters
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O

Parents

module serialization

serialization :: serialization

General serialization services

Children

module error

json :: error

Intro JsonParseError which is exposed by all JSON reading APIs
module model_parser_base

gamnit :: model_parser_base

Services to parse models from a text description
module sexp

sexp :: sexp

S-Expression parsing facilities
module xml_entities

dom :: xml_entities

Basic blocks for DOM-XML representation

Descendants

module a_star-m

a_star-m

module api

github :: api

Nit object oriented interface to Github api.
module at_boot

android :: at_boot

Import this module to launch Service at device boot
module bmfont

gamnit :: bmfont

Parse Angel Code BMFont format and draw text
module bundle

android :: bundle

A mapping class of String to various value types used by the
module cache

github :: cache

Enable caching on Github API accesses.
module cardboard

gamnit :: cardboard

Update the orientation of world_camera at each frame using the head position given by android::cardboard
module checker

dom :: checker

Simple XML validity checker using the dom module
module client

gamnit :: client

Client-side network services for games and such
module common

gamnit :: common

Services common to the client and server modules
module commonmark_gen

markdown2 :: commonmark_gen

Generate Nitunit tests from commonmark specification.
module curl_json

neo4j :: curl_json

cURL requests compatible with the JSON REST APIs.
module curl_rest

curl :: curl_rest

module data_store

android :: data_store

Implements app::data_store using shared_preferences
module data_store

linux :: data_store

app::data_store implementation on GNU/Linux
module data_store

ios :: data_store

Implements app::data_store using NSUserDefaults
module depth

gamnit :: depth

Framework for 3D games in Nit
module dom

dom :: dom

Easy XML DOM parser
module dynamic

json :: dynamic

Dynamic interface to read values from JSON strings
module error

neo4j :: error

Errors thrown by the neo4j library.
module events

github :: events

Events are emitted by Github Hooks.
module example_angular

popcorn :: example_angular

This is an example of how to use angular.js with popcorn
module flat

gamnit :: flat

Simple API for 2D games, built around Sprite and App::update
module github

github :: github

Nit wrapper for Github API
module graph

neo4j :: graph

Provides an interface for services on a Neo4j graphs.
module hooks

github :: hooks

Github hook event listening with nitcorn.
module http_request

android :: http_request

Android implementation of app:http_request
module http_request

linux :: http_request

Implementation of app::http_request using GDK and Curl
module http_request

app :: http_request

HTTP request services: AsyncHttpRequest and Text::http_get
module http_request

ios :: http_request

Implementation of app::http_request for iOS
module http_request_example

app :: http_request_example

Example for the app::http_request main service AsyncHttpRequest
module intent

android :: intent

Services allowing to launch activities and start/stop services using
module intent_api10

android :: intent_api10

Services allowing to launch activities and start/stop services using
module intent_api11

android :: intent_api11

Refines intent module to add API 11 services
module intent_api12

android :: intent_api12

Refines intent module to add API 12 services
module intent_api14

android :: intent_api14

Refines intent module to add API 14 services
module intent_api15

android :: intent_api15

Refines intent module to add API 15 services
module intent_api16

android :: intent_api16

Refines intent module to add API 16 services
module intent_api17

android :: intent_api17

Refines intent module to add API 17 services
module intent_api18

android :: intent_api18

Refines intent module to add API 18 services
module intent_api19

android :: intent_api19

Refines intent module to add API 19 services
module json

json :: json

Read and write JSON formatted text using the standard serialization services
module json_graph_store

neo4j :: json_graph_store

Provides JSON as a mean to store graphs.
module loader

github :: loader

module mongodb

mongodb :: mongodb

MongoDB Nit Driver.
module more_materials

gamnit :: more_materials

Various material implementations
module more_models

gamnit :: more_models

Services to load models from the assets folder
module mpi

mpi :: mpi

Implementation of the Message Passing Interface protocol by wrapping OpenMPI
module msgpack

msgpack :: msgpack

MessagePack, an efficient binary serialization format
module msgpack_to_json

msgpack :: msgpack_to_json

Convert MessagePack format to JSON
module mtl

gamnit :: mtl

Services to parse .mtl material files
module native_ui

android :: native_ui

Native services from the android.view and android.widget namespaces
module neo4j

neo4j :: neo4j

Neo4j connector through its JSON REST API using curl.
module network

gamnit :: network

Easy client/server logic for games and simple distributed applications
module nit_activity

android :: nit_activity

Core implementation of app.nit on Android using a custom Java entry point
module nlp

nlp :: nlp

Natural Language Processor based on the StanfordNLP core.
module nlp_index

nlp :: nlp_index

Example showing how to use a NLPFileIndex.
module obj

gamnit :: obj

Services to parse .obj geometry files
module parser

dom :: parser

XML DOM-parsing facilities
module pop_auth

popcorn :: pop_auth

Authentification handlers.
module pop_json

popcorn :: pop_json

Introduce useful services for JSON REST API handlers.
module pop_repos

popcorn :: pop_repos

Repositories for data management.
module pop_templates

popcorn :: pop_templates

Template rendering for popcorn
module pop_validation

popcorn :: pop_validation

Quick and easy validation framework for Json inputs
module queries

mongodb :: queries

Mongo queries framework
module restful

nitcorn :: restful

Support module for the nitrestful tool and the restful annotation
module restful_annot

nitcorn :: restful_annot

Example for the restful annotation documented at lib/nitcorn/restful.nit
module selection

gamnit :: selection

Select Actor from a screen coordinate
module sequential_id

neo4j :: sequential_id

Provides a sequential identification scheme for Neo4j nodes.
module serialization_read

msgpack :: serialization_read

Deserialize full Nit objects from MessagePack format
module serialization_read

json :: serialization_read

Services to read JSON: deserialize_json and JsonDeserializer
module server

gamnit :: server

Server-side network services for games and such
module service

android :: service

Android service support for app.nit centered around the class Service
module shared_preferences

android :: shared_preferences

Services allowing to save and load datas to internal android device
module shared_preferences_api10

android :: shared_preferences_api10

Services to save/load data using android.content.SharedPreferences for the android platform
module shared_preferences_api11

android :: shared_preferences_api11

Refines shared_preferences module to add API 11 services
module stanford

nlp :: stanford

Natural Language Processor based on the StanfordNLP core.
module static

json :: static

Static interface to read Nit objects from JSON strings
module stereoscopic_view

gamnit :: stereoscopic_view

Refine EulerCamera and App::frame_core_draw to get a stereoscopic view
module store

json :: store

Store and load json data.
module texture_atlas_parser

gamnit :: texture_atlas_parser

Tool to parse XML texture atlas and generated Nit code to access subtextures
module ui

linux :: ui

Implementation of the app.nit UI module for GNU/Linux
module ui

android :: ui

Views and services to use the Android native user interface
module ui_test

android :: ui_test

Test for app.nit's UI services
module virtual_gamepad

gamnit :: virtual_gamepad

Virtual gamepad mapped to keyboard keys for quick and dirty mobile support
module vr

gamnit :: vr

VR support for gamnit depth, for Android only
module wallet

github :: wallet

Github OAuth tokens management
module wifi

android :: wifi

Simple wrapper of the Android WiFi services
# Simple base for hand-made parsers of all kinds
module parser_base

import serialization

# Basic facilities for common parser operations on String sources
class StringProcessor
	# Source document to parse
	protected var src: String

	# Length of the source document
	protected var len: Int is noinit

	# Current position in `src`
	protected var pos = 0

	# Position at which current line started
	protected var line_start = 0

	# Current line in `src`
	protected var line = 1

	# Offset in the current line
	protected fun line_offset: Int do return pos - line_start + 1

	init do
		_len = src.length
	end

	# Gives the current location in the `src`
	fun current_location: Location do return new Location(line, line_offset)

	# Advances in `src` until a non-whitespace character is encountered
	protected fun ignore_whitespaces do
		var srclen = _len
		var p = _pos
		if p >= srclen then return
		var c = src[p]
		while c.is_whitespace do
			p += 1
			if p >= srclen then break
			if c == '\n' then
				_line += 1
				_line_start = p
			end
			c = src[p]
		end
		_pos = p
		return
	end

	# Reads characters until pattern `s` is found
	protected fun ignore_until(s: String): Int do
		if s.length == 0 then return _pos
		var srclen = _len
		var p = _pos
		if p >= srclen then return -1
		loop
			var c = s[0]
			var src_c = src[p]
			while src_c != c do
				p += 1
				if p >= srclen then
					_pos = p
					return -1
				end
				if src_c == '\n' then
					line += 1
					line_start= pos
				end
				src_c = src[p]
			end
			var relpos = p
			var fnd = true
			for i in s do
				if relpos >= srclen then
					fnd = false
					break
				end
				if src[relpos] != i then
					p += 1
					fnd = false
					break
				end
				relpos += 1
			end
			if fnd then
				_pos = p
				return p
			end
		end
	end

	# Ignores any printable character until a whitespace is encountered
	protected fun ignore_until_whitespace: Int do
		while src.length > pos and not src[pos].is_whitespace do pos += 1
		return pos
	end

	# Returns the current location as a `Location` object
	protected fun hot_location: Location do return new Location(line, line_offset)

	# Is `pos` at the end of the source?
	protected fun eof: Bool do return pos >= src.length
end

# Information about the location of an entity in a source document
class Location
	serialize

	# Line in which the element is described
	var line: Int
	# Offset in the line at which the element is positioned
	var offset: Int

	redef fun to_s do return "line {line}, position {offset}"
end

lib/parser_base/parser_base.nit:11,1--127,3