Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Close #356 - Add whitespace token for preprocessor #437

Merged
merged 25 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
295337d
Added whitespace token and made -E keep spacing, TODO consume whitespace
hdamron17 May 15, 2020
1514108
Filtered whitespace before parser, TODO debug a lot of test cases
hdamron17 May 15, 2020
33f9f12
Fix some bugs in whitespace handling
jyn514 May 15, 2020
dd628bf
Merge branch 'master' into preprocessor-whitespace
hdamron17 May 23, 2020
30be8d9
Add a oneline whitespace consumtion after #ifdef, #ifndef, #undef
hdamron17 May 23, 2020
60db031
Consume whitespace between function macro args
hdamron17 May 23, 2020
30eac7f
Fixed most of lex::tests::*
hdamron17 May 23, 2020
f0c146e
Handle lex::tests::test_no_newline
hdamron17 May 23, 2020
8e0509e
Changed analyze::test::lol to not have leading newline
hdamron17 May 23, 2020
01f040b
Added whitespace between hash and directive
hdamron17 May 23, 2020
d51af7e
Remove trailing newline for -E
hdamron17 May 23, 2020
f671f65
Handle spaces in defines and whitespace in comments
hdamron17 May 24, 2020
36b7fc3
Handle lex::tests::test_no_newline (again)
hdamron17 May 24, 2020
675989b
Fix error messages for macros and #ifdef
hdamron17 May 24, 2020
1d5578f
Rework whitespace in tokens_until_newline
hdamron17 May 24, 2020
c1aa84a
De Morgan
hdamron17 May 24, 2020
81d47d9
cargo fmt
hdamron17 May 24, 2020
bbbb3ab
Add a few tests for preprocess only with exact matching
hdamron17 May 24, 2020
46b4943
Make Whitespace matches consistently use ..
hdamron17 May 25, 2020
78ad8fc
Fixed issue with whitespace at beginning of analyze::test::lol in `pa…
hdamron17 May 25, 2020
8c4f568
Clean up filter_map thanks to @jyn514
hdamron17 May 25, 2020
0e055b9
Get tokens_until_newline to do what it's name suggests and other whit…
hdamron17 May 25, 2020
3a9cd4a
More preprocess_only tests
hdamron17 May 25, 2020
6d084cd
Merge two versions of `is_not_whitespace`
hdamron17 May 25, 2020
0d03378
Do not assume there is whitespace between define id and body
hdamron17 May 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/data/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,12 @@ pub enum CppError {
#[error("expected expression for #if")]
EmptyExpression,

#[error("macro name missing")]
ExpectedMacroId,

#[error("missing {0} in {1}")]
Expected(&'static str, &'static str),

/// A `#define` occured without an identifier following.
#[error("macro name missing")]
EmptyDefine,
Expand Down
4 changes: 4 additions & 0 deletions src/data/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ pub enum Token {
Literal(Literal),
Id(InternedStr),

Whitespace(String),

// Misc
Ellipsis,
StructDeref, // ->
Expand Down Expand Up @@ -353,6 +355,8 @@ impl std::fmt::Display for Token {
Id(id) => write!(f, "{}", id),
Keyword(k) => write!(f, "{}", k),

Whitespace(s) => write!(f, "{}", s),

Ellipsis => write!(f, "..."),
StructDeref => write!(f, "->"),
Hash => write!(f, "#"),
Expand Down
Loading