Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Chibicc
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
邓家琪
Chibicc
Commits
2e15e2b8
Commit
2e15e2b8
authored
4 years ago
by
Rui Ueyama
Browse files
Options
Downloads
Patches
Plain Diff
Add a do-nothing preprocessor
parent
f51e65a0
Branches
Branches containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
chibicc.h
+7
-0
7 additions, 0 deletions
chibicc.h
main.c
+1
-0
1 addition, 0 deletions
main.c
preprocess.c
+7
-0
7 additions, 0 deletions
preprocess.c
tokenize.c
+1
-2
1 addition, 2 deletions
tokenize.c
with
16 additions
and
2 deletions
chibicc.h
+
7
−
0
View file @
2e15e2b8
...
...
@@ -69,11 +69,18 @@ void warn_tok(Token *tok, char *fmt, ...);
bool
equal
(
Token
*
tok
,
char
*
op
);
Token
*
skip
(
Token
*
tok
,
char
*
op
);
bool
consume
(
Token
**
rest
,
Token
*
tok
,
char
*
str
);
void
convert_keywords
(
Token
*
tok
);
Token
*
tokenize_file
(
char
*
filename
);
#define unreachable() \
error("internal error at %s:%d", __FILE__, __LINE__)
//
// preprocess.c
//
Token
*
preprocess
(
Token
*
tok
);
//
// parse.c
//
...
...
This diff is collapsed.
Click to expand it.
main.c
+
1
−
0
View file @
2e15e2b8
...
...
@@ -183,6 +183,7 @@ static void run_cc1(int argc, char **argv, char *input, char *output) {
static
void
cc1
(
void
)
{
// Tokenize and parse.
Token
*
tok
=
tokenize_file
(
base_file
);
tok
=
preprocess
(
tok
);
Var
*
prog
=
parse
(
tok
);
// Traverse the AST to emit assembly.
...
...
This diff is collapsed.
Click to expand it.
preprocess.c
0 → 100644
+
7
−
0
View file @
2e15e2b8
#include
"chibicc.h"
// Entry point function of the preprocessor.
Token
*
preprocess
(
Token
*
tok
)
{
convert_keywords
(
tok
);
return
tok
;
}
This diff is collapsed.
Click to expand it.
tokenize.c
+
1
−
2
View file @
2e15e2b8
...
...
@@ -332,7 +332,7 @@ static Token *read_number(Token *cur, char *start) {
return
tok
;
}
static
void
convert_keywords
(
Token
*
tok
)
{
void
convert_keywords
(
Token
*
tok
)
{
for
(
Token
*
t
=
tok
;
t
->
kind
!=
TK_EOF
;
t
=
t
->
next
)
if
(
is_keyword
(
t
))
t
->
kind
=
TK_RESERVED
;
...
...
@@ -449,7 +449,6 @@ static Token *tokenize(char *filename, char *p) {
new_token
(
TK_EOF
,
cur
,
p
,
0
);
add_line_numbers
(
head
.
next
);
convert_keywords
(
head
.
next
);
return
head
.
next
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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