Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JarryShaw/Compiler
Assignments of Compiler (SJTU)
https://github.com/JarryShaw/Compiler
compiler flex lex
Last synced: 5 days ago
JSON representation
Assignments of Compiler (SJTU)
- Host: GitHub
- URL: https://github.com/JarryShaw/Compiler
- Owner: JarryShaw
- License: mit
- Archived: true
- Created: 2017-10-30T06:31:57.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-26T12:30:13.000Z (over 6 years ago)
- Last Synced: 2024-05-22T19:32:14.649Z (6 months ago)
- Topics: compiler, flex, lex
- Language: Lex
- Size: 326 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-scs - 2017 - Compiler
README
# Compiler
> This repository maintains some assignments (projects / labs) during **Compiler** (SJTU).
### Lexical Analysis
Indicate a lexical analysis program using `Lex` language for `Python` sources. The program should be able to
- convert non-decimal numbers to decimal
- convert uppercase comments to lowercaseas the following example shows.
> The original file goes like this …
```python
#!/usr/bin/env python'''Main FUCTION'''
def main():
a = (0o21 + 0x1c) * 2 # 0o21 equals 17
b = 0b1001 * 0O37 # 0b1001 eqUALs 9
c = 0XA1 - 55 # 0XA1 equals 161
d = 0101 # 0101 EQUALS 65
print a + b - c - d
'''END'''if __name__ == '__main__':
"""
CALL
main function
"""
main()
```> And afterwards, it should be like …
```python
#!/usr/bin/env python'''main fuction'''
def main():
a = (17 + 28) * 2 # 0o21 equals 17
b = 9 * 31 # 0b1001 equals 9
c = 161 - 55 # 0xa1 equals 161
d = 65 # 0101 equals 65
print a + b - c - d
'''end'''if __name__ == '__main__':
"""
call
main function
"""
main()
```According to the requirements, the program should be run and tested with scripts bellow.
```bash
$ flex flex.l # > lex.yy.c
$ gcc lex.yy.c -lfl # > a.out
$ ./a.out < test.py > result.py # in default
```But due to some other reasons, the test sample and corresponding result are stored in `test` and `result`.