Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Compiler_hw1_lexical_analyzer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lang0909
Compiler_hw1_lexical_analyzer
Commits
2e41bcee
Commit
2e41bcee
authored
5 years ago
by
lang0909
Browse files
Options
Downloads
Patches
Plain Diff
Update README.md
parent
5e09e9a1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+36
-17
36 additions, 17 deletions
README.md
with
36 additions
and
17 deletions
README.md
+
36
−
17
View file @
2e41bcee
...
...
@@ -7,7 +7,6 @@
-
Ubuntu 18.04.1 LTS (64bit)
-
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
-
flex 2.6.4
-
## 사용 시 주의사항
### lex file을 flex를 이용하여 c 파일을 생성후 gcc로 컴파일 후 생성 된 object 파일을 이용하여 사용
...
...
@@ -23,62 +22,82 @@ gcc lex.yy.c -lf -lfl
## 기능 설명
### TOKEN 종류
Keywords
int double str if while return
Identifiers (ID)
1.
Keywords
-int double str if while return
2.
Identifiers (ID)
-
영문자 대소문자, 숫자, underscore(_)로만 이루어짐
-
첫 글자는 반드시 대소문자, _만 가능
-
‘_’문자만으로 이루어질 수는 없음
-
길이는 제한이 없으나 실제 구분은 첫 16자로 함
INTEGER
3.
INTEGER
-
기본적으로 C 언어의 int 표기법을 따름 (십진수만 사용)
-
자리 수는 제한 없으나 값을 저장 시 최대 10자리만 저장(11자리 이상은 상위부분 절단)
DOUBLE
4.
DOUBLE
-
C 언어의 double constant 표기법을 따름
STRING
5.
STRING
-
기본적으로 C 언어의 표기법을 따름
Operators
+
-
*
/
=
> >= < <= == !=
기타 특수 문자들
" , ( ) ; { }
6.
Operators
-
+ -
*
/
-
=
-
> >= < <= == !=
7.
기타 특수 문자들
-
" , ( ) ; { }
Comments
C언어의 주석을 따른다 ( /
* *
/ 와 // )
8.
Comments
-
C언어의 주석을 따른다 ( /
* *
/ 와 // )
### 입력예시
int f ( int a, double b)
{
int sum;
sum = a + b;
print(a, b, sum);
}
int sum ; sum print ( ;
**실제 문장구조는 체크하지 않으므로 실제 문법과 달라도 상관없음**
int sum ; sum print ( ;
**실제 문장구조는 체크하지 않으므로 실제 문법과 달라도 상관없음**
## 출력예시
-
1. 토큰들의 리스트 (token 옆에 lexeme을 함께 출력할 것)
TOKEN LEXEME
<INT, > int
<ID, 1> f
<LPAREN
,
>
(
<INT
,
>
int
<ID
,
2
>
a
<COMMA
,
>
,
...
<PRINT
,
>
print
<LPAREN
,
>
(
<ID
,
2
>
a
<COMMA
,
>
,
<ID
,
3
>
b
<COMMA
,
>
,
...
-
2. 심볼테이블 및 스트링 테이블
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment