diff --git a/README.md b/README.md index c6e3ef4..48a79c6 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,62 @@ # Rat24S Compiler +A compiler for Rat24S language is designed to be an easy to understand. It has a short grammar and relatively clean semantics. -#### Test Case 1 +## Usage +Here is a simple example of checking a source code file for syntax errors, and print out to the console all the production rules used during syntax analyzing: ```bash -python3 main.py test_case_1.txt output_1.txt +python3 rat24s.py input.txt -o output.txt -v ``` +**Optional arguments** +The Rat24S compiler has many options for reading input from a file, writing output to a file, extracting the tokens, and checking your code syntax. +|Flag|Full tag|Description| +|--|--|--| +|`-o`|`--output`|Output file path.| +|`-t`|`--tokens`|Extract tokens only, but don't do anything beyond that.| +|`-v`|`--verbose`|Enable verbose mode.| -#### Test Case 2 -```bash -python3 main.py test_case_2.txt output_2.txt +# Documentations +#### High level diagram +```mermaid +graph LR +START:::hidden -- source code--> LA[Lexical Analyzer] +LA--tokens-->SA[Syntax Analyzer] +SA-->T((Correct)) +SA-->F((Error)) +classDef hidden display: none; +``` +#### Grammar Rules +``` +R1. ::= $ $ $ $ +R2. ::= | +R3. ::= | +R4. ::= function ( ) +R5. ::= | +R6. ::= | , +R7. ::= +R8. ::= integer | boolean | real +R9. ::= { < Statement List> } +R10. ::= | +R11. := ; | ; +R12. ::= +R13. ::= | , +R14. ::= | +R15. ::= | | | | | | +R16. ::= { } +R17. ::= = ; +R18. ::= if ( ) endif | if ( ) else endif +R19. ::= return ; | return ; +R20. ::= print ( ); +R21. ::= scan ( ); +R22. ::= while ( ) endwhile +R23. ::= +R24. ::= == | != | > | < | <= | => +R25. ::= + | - | +R26. ::= * | / | +R27. ::= - | +R28. ::= | | ( ) | ( ) | + | true | false +R29. ::= ε ``` -#### Test Case 3 -```bash -python3 main.py test_case_3.txt output_3.txt -``` \ No newline at end of file +# License +This project is licensed under the MIT license - see the [LICENSE.md](LICENSE.md) file for details. \ No newline at end of file