Skip to content

Commit

Permalink
[Phase2] Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
liqwang committed Dec 4, 2023
1 parent 4a91129 commit 9369c46
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions phase2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,21 @@

```shell
> make splc #compile the splc compiler for SPL language
> make test #compile the compiler and run test cases
> make clean #clean the directory
> make lexer #using lex.l to compile the lexer for debug
```


## Design
- Using class `rec` as a node, there are types var, fun, arr, etc., and actions usfun, usassign, etc
- Create initial node in lex
- In Bison, define first, obtain a global map, link the desired elements on the nodes of all action types and then judge the action type of each node


## Traverse Parse Tree
- When DFS traverse the tree, the node of the action type is assigned a value of the corresponding type, which is convenient for use in nested calls later
- In the `recs` of `rec`, for the array will store the value related to its size, the number of values represents the number of dimensions, for `Exp` expression we will store the result of the operation in the val property of rec, for return will look for a specific statement, get its val


## Bonus
- Tests for undefined variables are performed
- The processing of arrays will help us to check the array overreach

0 comments on commit 9369c46

Please sign in to comment.