+//Creates a scanner state which will be useful for accessing the lexer later.
+pl_create_scanner (const gchar* input)
+ assert (input != NULL);
+ assert (g_utf8_validate (input, -1, NULL));
+ state = (LexerState *) malloc (sizeof (LexerState));
+ assert (state != NULL);
+ state->stream = g_strdup (input);
+ state->length = strlen (state->stream); //Can't find a GLib replacement of strlen. The mailing list discussion says, it is not implemented because strlen is perfectly capable. :)
+//Destroy and free memory used by LexerState object.
+pl_destroy_scanner (LexerState * state)
+//Roll back last scanned unichar.
+pl_roll_back (LexerState * state)
+ tmp = g_utf8_find_prev_char (state->stream, state->stream + state->next_index);
+ state->next_index = tmp - state->stream;
+//Get validated gunichar from input stream.
+pl_get_next_gunichar (LexerState * state)
+ if (state->next_index >= state->length)
+ ret = g_utf8_get_char_validated (state->stream + state->next_index, -1);
+ state->next_index = g_utf8_next_char (state->stream + state->next_index) - state->stream;
+//Set marker index. To be used for highlighting and error reporting.
+pl_set_marker (LexerState * state)
+ state->mark_index = state->next_index;
+//Get marked substring. To be used for error reporting.
+pl_get_marked_substring (LexerState * state)
+ return g_strndup (state->stream + state->mark_index, state->next_index - state->mark_index);