-
Notifications
You must be signed in to change notification settings - Fork 0
/
documentation lab3.txt
18 lines (16 loc) · 1.36 KB
/
documentation lab3.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
link to Git Repo: https://github.com/GorbataiCristian/LFTC
"parser.py" contains the parser implementation.
We use a class named Token to store each token and the row it appears in.
we use a function to write a list of elememts into a file.
"chech_tokens_from_file" validates all tokens from a file and if the file is
lexically correct prints writes the content from PIF, the identifier symbol table and the
constant symbol table into 3 output files.
A file is considered lexically corect if all it's tokens either appear in the "token.in" file or
if they are a valid identifier or constant(integer, rational, string)
- IDENTIFIER: any word that starts with a letter or an underscore and is followed by any number of letters, underscores or digits
- INTEGER: 0 or any non-zero digit followed by any number of digits preceeded by an optional minus or plus sign
- RATIONAL: an INTEGER followed by a '.' (point) succeeded by any number of digits
- STRING: any nummber of characters between single quotes (')
PIF is a list containing pairs (token, id) where id=-1 of token is in "token.in" file(not an identifier or constant)
if the token is an identifier or constant then we do not put the actual token in PIF but a label ("constant" or "identifier").
ST is a binary search tree with add and delete implemented(if needed), add also returns the id of the newly created or existing element.