@@ -72,7 +72,7 @@ fn compress_action_table(
7272 fn find_most_common_action (
7373 uncompressed_action_table : & [ i16 ] ,
7474 state_index : usize ,
75- terminal_symbols : & Vec < Component > ,
75+ terminal_symbols : & [ Component ] ,
7676 ) -> i16 {
7777 let mut cnt: BTreeMap < i16 , u16 > = BTreeMap :: new ( ) ;
7878 for j in 0 ..terminal_symbols. len ( ) {
@@ -116,19 +116,14 @@ fn compress_action_table(
116116 ok = false ;
117117 break ;
118118 }
119- } else {
120- if index_check[ i + j] == j as i16 {
121- if compressed_values[ i + j] != a {
122- ok = false ;
123- break ;
124- }
125- } else if index_check[ i + j] != UNUSED_ENTRY_CODE {
126- ok = false ;
127- break ;
128- } else if offset_used[ i] {
119+ } else if index_check[ i + j] == j as i16 {
120+ if compressed_values[ i + j] != a {
129121 ok = false ;
130122 break ;
131123 }
124+ } else if index_check[ i + j] != UNUSED_ENTRY_CODE || offset_used[ i] {
125+ ok = false ;
126+ break ;
132127 }
133128 }
134129
@@ -154,7 +149,7 @@ fn compress_action_table(
154149 let max_table_index = * state_to_offset. iter ( ) . max ( ) . unwrap ( ) as usize + terminal_symbols. len ( ) ;
155150
156151 let info = CompressedParserTable {
157- state_to_offset : state_to_offset ,
152+ state_to_offset,
158153 compressed_values : compressed_values[ ..max_table_index] . to_vec ( ) ,
159154 index_check : index_check[ ..max_table_index] . to_vec ( ) ,
160155 } ;
@@ -199,19 +194,14 @@ fn compress_goto_table(
199194 ok = false ;
200195 break ;
201196 }
202- } else {
203- if index_check[ i + j] == j as i16 {
204- if compressed_values[ i + j] != a {
205- ok = false ;
206- break ;
207- }
208- } else if index_check[ i + j] != UNUSED_ENTRY_CODE {
209- ok = false ;
210- break ;
211- } else if offset_used[ i] {
197+ } else if index_check[ i + j] == j as i16 {
198+ if compressed_values[ i + j] != a {
212199 ok = false ;
213200 break ;
214201 }
202+ } else if index_check[ i + j] != UNUSED_ENTRY_CODE || offset_used[ i] {
203+ ok = false ;
204+ break ;
215205 }
216206 }
217207
@@ -236,13 +226,11 @@ fn compress_goto_table(
236226 let max_table_index =
237227 * state_to_offset. iter ( ) . max ( ) . unwrap ( ) as usize + non_terminal_symbols. len ( ) ;
238228
239- let info = CompressedParserTable {
240- state_to_offset : state_to_offset ,
229+ CompressedParserTable {
230+ state_to_offset,
241231 compressed_values : compressed_values[ ..max_table_index] . to_vec ( ) ,
242232 index_check : index_check[ ..max_table_index] . to_vec ( ) ,
243- } ;
244-
245- info
233+ }
246234}
247235
248236fn generate_parser_source_code (
@@ -259,8 +247,8 @@ fn generate_parser_source_code(
259247 . join ( "," )
260248 }
261249
262- let ( action_table_info, def_rules) = compress_action_table ( lalr, & terminal_symbols) ;
263- let goto_table_info = compress_goto_table ( lalr, & non_terminal_symbols) ;
250+ let ( action_table_info, def_rules) = compress_action_table ( lalr, terminal_symbols) ;
251+ let goto_table_info = compress_goto_table ( lalr, non_terminal_symbols) ;
264252
265253 let terminal_symbols_with_comment = terminal_symbols
266254 . iter ( )
@@ -378,9 +366,9 @@ fn generate_parser_source_code(
378366}
379367
380368fn generate_syntax_kinds_source_code (
381- terminal_symbols : & Vec < Component > ,
382- non_terminal_symbols : & Vec < Component > ,
383- comments : & Vec < Component > ,
369+ terminal_symbols : & [ Component ] ,
370+ non_terminal_symbols : & [ Component ] ,
371+ comments : & [ Component ] ,
384372) {
385373 let mut kinds = Vec :: new ( ) ;
386374 for c in terminal_symbols
0 commit comments