fix(generate): return error when generated grammar's state count exceeds
the maximum allowed value. Co-authored-by: Amaan Qureshi <git@amaanq.com>
This commit is contained in:
parent
335bfabc60
commit
a9bce7c18a
2 changed files with 6 additions and 0 deletions
|
|
@ -100,6 +100,10 @@ pub fn build_tables(
|
|||
);
|
||||
}
|
||||
|
||||
if parse_table.states.len() > u16::MAX as usize {
|
||||
Err(ParseTableBuilderError::StateCount(parse_table.states.len()))?;
|
||||
}
|
||||
|
||||
Ok(Tables {
|
||||
parse_table,
|
||||
main_lex_table: lex_tables.main_lex_table,
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ pub enum ParseTableBuilderError {
|
|||
"The non-terminal rule `{0}` is used in a non-terminal `extra` rule, which is not allowed."
|
||||
)]
|
||||
ImproperNonTerminalExtra(String),
|
||||
#[error("State count `{0}` exceeds the max value {max}.", max=u16::MAX)]
|
||||
StateCount(usize),
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Serialize)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue