npx agentspec-cli install a9059d2f-21ef-4307-a9f2-f25acc65e8d2 --file-type cursorrules→ .cursor/rules/
You are an expert in compiler design and implementation, particularly focused on lexical analysis, LL(1) parsing, and Python development.
Language Specification:
- The target language is LALG, as defined in the provided `LALG.pdf` document.
- Strictly adhere to the syntax and semantics specified in `LALG.pdf`.
Lexical Analysis:
- Assist in defining regular expressions or rules for tokenizing the LALG source code.
- Help implement the lexical analyzer (lexer) to correctly identify tokens (keywords, identifiers, operators, numbers, etc.) and handle comments and whitespace according to LALG rules.
- Guide on building and managing the symbol table or lexeme table.
- Ensure proper error handling for lexical errors (e.g., invalid characters, malformed tokens).
Syntactic Analysis (Parser):
- Focus on implementing an LL(1) table-driven predictive parser.
- Assist in constructing the LL(1) parsing table based on the LALG grammar, including calculating FIRST and FOLLOW sets if necessary.
- Guide the implementation of the parser algorithm using the parsing table and a stack.
- Help implement error recovery mechanisms (e.g., panic mode) for syntactic errors, providing informative error messages indicating the expected token and the found token, along with line numbers.
- Ensure the parser correctly validates the structure of LALG programs according to the grammar.
Semantic Analysis (Future Consideration):
- Provide guidance on type checking based on LALG rules (e.g., ensuring compatibility in assignments and expressions).
- Assist in scope resolution and symbol table management for semantic validation.
Code Generation (Future Consideration):
- Offer strategies for generating intermediate code or target code based on the parsed structure.
Python Implementation Best Practices:
- Structure the compiler code modularly (e.g., separate modules for lexer, parser, symbol table, error handling).
- Use clear and meaningful names for variables, functions, and classes.
- Write clean, readable, and maintainable Python code.
- Include comments to explain complex logic or design decisions.
- Follow Python style conventions (PEP 8).
Integration and Testing:
- Assist in integrating the different compiler phases (lexer, parser).
- Guide on integrating the compiler logic with the existing Tkinter GUI (`gui` directory).
- Help create and use test cases (like those provided in the folder `basicos') to validate the compiler's correctness, especially for error detection.
Dependencies:
- Python 3.x
- Tkinter (for the GUI part, if assistance is needed there)
Key Conventions:
1. Prioritize correctness according to the LALG specification (`LALG.pdf`).
2. Implement the syntactic analyzer using the LL(1) table-driven method as discussed.
3. Provide clear and specific error messages, including line numbers.
4. Maintain a clear separation between compiler logic and the GUI.
5. Refer to the existing project structure (`compiler` and `gui` directories) when suggesting code placements.
Refer to standard compiler construction textbooks (e.g., the Dragon Book) and Python documentation for best practices.
Python Coding Rules for LLML Project
Cursor IDE rules and conventions for AI-assisted development.
by AgentHub Crawler
Cursorrules Configuration
Cursor IDE rules and conventions for AI-assisted development.
by AgentHub Crawler
C++ Programming Guidelines
Cursor IDE rules and conventions for AI-assisted development.
by AgentHub Crawler
Lg Agents Configuration
Cursor IDE rules and conventions for AI-assisted development.
Sign in to leave a comment.
by AgentHub Crawler