Move public types to the top
This commit is contained in:
parent
779ba052c1
commit
e0e5e87338
@ -1,14 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*
|
||||||
|
* This file is generated by Propane.
|
||||||
|
*/
|
||||||
|
|
||||||
<% if @grammar.modulename %>
|
<% if @grammar.modulename %>
|
||||||
module <%= @grammar.modulename %>;
|
module <%= @grammar.modulename %>;
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* User code blocks
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
<% @grammar.code_blocks.each do |code| %>
|
<% @grammar.code_blocks.each do |code| %>
|
||||||
<%= code %>
|
<%= code %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Public types
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
/* Result codes. */
|
/* Result codes. */
|
||||||
public enum : size_t
|
public enum : size_t
|
||||||
{
|
{
|
||||||
@ -20,9 +33,6 @@ public enum : size_t
|
|||||||
P_EOF,
|
P_EOF,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An invalid ID value. */
|
|
||||||
private enum size_t INVALID_ID = cast(size_t)-1;
|
|
||||||
|
|
||||||
/** Token ID type. */
|
/** Token ID type. */
|
||||||
public alias Token = <%= get_type_for(@grammar.invalid_token_id) %>;
|
public alias Token = <%= get_type_for(@grammar.invalid_token_id) %>;
|
||||||
|
|
||||||
@ -38,13 +48,6 @@ public enum : Token
|
|||||||
INVALID_TOKEN_ID = <%= @grammar.invalid_token_id %>,
|
INVALID_TOKEN_ID = <%= @grammar.invalid_token_id %>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Token names. */
|
|
||||||
public static immutable string[] token_names = [
|
|
||||||
<% @grammar.tokens.each_with_index do |token, index| %>
|
|
||||||
"<%= token.name %>",
|
|
||||||
<% end %>
|
|
||||||
];
|
|
||||||
|
|
||||||
/** Code point type. */
|
/** Code point type. */
|
||||||
public alias CodePoint = uint;
|
public alias CodePoint = uint;
|
||||||
|
|
||||||
@ -70,6 +73,42 @@ public static struct Position
|
|||||||
uint col;
|
uint col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lexed token information.
|
||||||
|
*/
|
||||||
|
public static struct TokenInfo
|
||||||
|
{
|
||||||
|
/** Text position where the token was found. */
|
||||||
|
Position position;
|
||||||
|
|
||||||
|
/** Number of input bytes used by the token. */
|
||||||
|
size_t length;
|
||||||
|
|
||||||
|
/** Token identifier. */
|
||||||
|
Token token;
|
||||||
|
|
||||||
|
/** Parser value associated with the token. */
|
||||||
|
ParserValue pvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Public data
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
/** Token names. */
|
||||||
|
public static immutable string[] token_names = [
|
||||||
|
<% @grammar.tokens.each_with_index do |token, index| %>
|
||||||
|
"<%= token.name %>",
|
||||||
|
<% end %>
|
||||||
|
];
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Private types
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
/* An invalid ID value. */
|
||||||
|
private enum size_t INVALID_ID = cast(size_t)-1;
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Decoder
|
* Decoder
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
@ -216,14 +255,6 @@ private static immutable Mode[] modes = [
|
|||||||
<% end %>
|
<% end %>
|
||||||
];
|
];
|
||||||
|
|
||||||
public static struct TokenInfo
|
|
||||||
{
|
|
||||||
Position position;
|
|
||||||
size_t length;
|
|
||||||
Token token;
|
|
||||||
ParserValue pvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Lexer
|
public static class Lexer
|
||||||
{
|
{
|
||||||
private string m_input;
|
private string m_input;
|
||||||
@ -349,7 +380,7 @@ public static class Lexer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MatchInfo
|
private struct MatchInfo
|
||||||
{
|
{
|
||||||
size_t length;
|
size_t length;
|
||||||
Position delta_position;
|
Position delta_position;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user