Welcome to the collection of code snippets related to compiler design! Here, you'll find a range of helpful scripts and functions to streamline the process of parsing and analyzing programming languages. Whether you're a seasoned programmer or just starting out, this repo is sure to make your life easier!
making_life_easy.py
This code can be used to count the number of comments and lines in a given file. It is useful for analyzing code metrics.
Code to detect and categorize keywords, operators, delimiters, identifiers, and numbers in a given text
This code can be used to detect and categorize different elements of a programming language, such as keywords, operators, delimiters, identifiers, and numbers. It is useful for building lexers.
Code to check for left recursion in a given grammar and, if present, to eliminate it using the left factoring method
This code can be used to check for left recursion in a given grammar and eliminate it using the left factoring method. Left recursion can cause infinite loops in a parser, so it is important to remove it.
Code to remove left recursion from a given context-free grammar and to calculate the first set of each non-terminal symbol
This code defines several functions to remove left recursion from a given context-free grammar and to calculate the first set of each non-terminal symbol. The first set is used to build a parsing table.
This code can be used to find the first set of each non-terminal symbol in a given context-free grammar. The first set is used to build a parsing table.
This code can be used to find the follow set of each non-terminal symbol in a given context-free grammar. The follow set is used to build a parsing table.
This code can be used to print the parsing table for a given context-free grammar using the first and follow sets of each non-terminal symbol. The parsing table is used by the LL(1) parser.
This Python code implements the LL(1) parser for a given context-free grammar. The LL(1) parser uses a parsing table to parse a given input string.
This code can be used to generate an operator precedence table for a given set of operators. The operator precedence table is used by the parser to resolve operator ambiguities.
This code can be used to generate an operator function table for a given set of operators. The operator function table maps each operator to its corresponding function.
This code implements the SLR parser for a given context-free grammar. The SLR parser uses a state machine to parse a given input string.
