Docs for the shared Ragel grammar.

This commit is contained in:
Yorick Peterse 2014-05-08 00:21:23 +02:00
parent 98db796205
commit c472ceac6f
1 changed files with 27 additions and 0 deletions

View File

@ -1,6 +1,33 @@
%%machine base_lexer;
%%{
##
# Base grammar for the XML lexer.
#
# This grammar is shared between the C and Java extensions. As a result of
# this you should **not** include language specific code in Ragel
# actions/callbacks.
#
# To call back in to Ruby you can use one of the following two functions:
#
# * callback
# * callback_simple
#
# The first function takes 5 arguments:
#
# * The name of the Ruby method to call.
# * The input data.
# * The encoding of the input data.
# * The start of the current buffer.
# * The end of the current buffer.
#
# The function callback_simple only takes one argument: the name of the
# method to call. This function should be used for callbacks that don't
# require any values.
#
# When you call a method in Ruby make sure that said method is defined as
# an instance method in the `Oga::XML::Lexer` class.
newline = '\n' | '\r\n';
whitespace = [ \t];
identifier = [a-zA-Z0-9\-_:]+;