Add description of the format of parsing table
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 14 Jun 2024 10:36:31 +0000 (12:36 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Fri, 14 Jun 2024 10:36:31 +0000 (12:36 +0200)
inc/ft_parse.h

index d34bd6a35930624ad12c130b96b71271ed36e0ab..4c579da992c674737cb15f4bea6cd4802561624c 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <ljiriste@student.42prague.com>   +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/05/27 21:21:54 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/05/27 22:57:11 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/06/14 11:20:28 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -39,10 +39,30 @@ typedef struct s_parser_state
        t_vec   gotos;                          // t_vec of size_t
 }                      t_parser_state;
 
+//     The states table has the following form:
+//
+//     State token[i]               token[i+n]
+//     j     states[j].lookahead[i] states[0].goto[i]
+//
+//     The whitespace is not significant and ; should be used as separator
+//
+//     The first row contains all the n terminal tokens first
+//     and after them all the non-terminal tokens.
+//     Every other row contains the (unique) state number and the reduce/shift
+//     rule for the appropriate token.
+//
+//     The rules table should have the form
+//
+//     token[i_1] -> [ token[j_1] [ token[k_1] ... ]]
+//     token[i_2] -> [ token[j_2] [ token[k_2] ... ]]
+//
+//     Tokens should not contain whitespace as it is used as separator
+
 typedef struct s_parsing_table
 {
        t_vec   rules;                          // t_vec of t_grammar_rule
        t_vec   states;                         // t_vec of t_parser_state
+       t_vec   tokens;                         // t_vec of tokens
 }                      t_parsing_table;
 
 #endif // FT_PARSE_H