Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
UchihaIthachi committed Apr 12, 2024
1 parent 34f48f7 commit 64e85e9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ pip install -r requirements.txt
```

4. Put your RPAL test programs in the root directory. We had added the [test.txt](https://github.com/malinduGamage/RPAL-Interpreter/blob/main/test.txt) to the root directory, which contains the sample input program of the [Project_Requirements](https://github.com/malinduGamage/RPAL-Interpreter/blob/main/doc/ProgrammingProject.pdf) document.
Run the main script `main.py` with the file name as an argument:
Run the main script `myrpal.py` with the file name as an argument:

```bash
python main.py file_name
python .\myrpal.py file_name
```

The following sequence of commands can be used in the root of the project directory to compile the program and execute RPAL programs:

To generate the Abstract Syntax Tree:

```bash
python main.py -ast file_name
python .\myrpal.py -ast file_name
```

> #### screenshot about the switches
Expand All @@ -72,25 +72,25 @@ Screenshots of functioning switches can be found in the [docs/working_switches](
To generate the token list from the lexical analyzer:

```bash
python main.py -t file_name
python .\myrpal.py -t file_name
```

To generate the filtered token list from the screen:

```bash
python main.py -ft file_name
python .\myrpal.py -ft file_name
```

To generate the Standardized Tree:

```bash
python main.py -st file_name
python .\myrpal.py -st file_name
```

To generate the CSE table:

```bash
python main.py -ct file_name
python .\myrpal.py -ct file_name
```

#### Using Make Commands (Alternative Method)
Expand Down Expand Up @@ -223,7 +223,7 @@ The RPAL interpreter project is structured into several components, each respons

```bash
RPAL-Interpreter/
├── main.py # Main entry point of the application
├── myrpal.py # Main entry point of the application
|
├── lexical_analyzer/ # Package for lexical analysis functionality
│ ├── scanner.py # Module containing lexical scanner logic
Expand Down
1 change: 1 addition & 0 deletions cse_machine/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ def _add_table_data(self, rule):
add_table_data(self, rule)

def _print_cse_table(self):
self._linearizer.print_control_structures()
print_cse_table(self)

def _generate_output(self):
Expand Down
3 changes: 2 additions & 1 deletion cse_machine/utils/STlinearizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def print_control_structures(self):
"""
Print the control structures.
"""
print('\n')
print()
print('Control Structures',end="\n\n")
for structure in self.control_structures:
print(f"δ_{structure.index} = ",end="")
for element in structure.elements:
Expand Down
6 changes: 6 additions & 0 deletions lexical_analyzer/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ def token_scan(self, str):
ScannerError
If an invalid character or token is encountered.
"""
# check if the input string ends with a newline character
# and if so, print a warning message
if str[-1] != '\n':
line = len(str.split('\n'))
print("Potential parse problem--tokens remain.")
print(f"Remaining tokens begin at line {line}.")

token = ''
currState = 0
Expand Down
1 change: 0 additions & 1 deletion screener/token_screener.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def screener(self, tokens):
for token in tokens:
# Remove tokens marked for deletion or EOF tokens
if token.get_type() == 'DELETE':
# print(token.get_type())
continue
# Remove IDENTIFIER tokens if they match any keywords
elif token.get_type() == 'ID' and token.get_value() in self.keywords:
Expand Down
2 changes: 1 addition & 1 deletion test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let Sum(A) = Psum (A,Order A )
where rec Psum (T,N) = N eq 0 -> 0
| Psum(T,N-1)+T N
in Print ( Sum (1,2,3,4,5) ) ////this is it
in Print ( Sum (1,2,3,4,5) )

0 comments on commit 64e85e9

Please sign in to comment.