Commit Graph

192716 Commits

Author SHA1 Message Date
Arthur Cohen 6db51e3936 subs_repetition: Add simple test cases 2022-02-22 12:06:27 +01:00
Arthur Cohen ded1aca902 substitute_repetition: Substitute repetitions properly 2022-02-22 12:06:27 +01:00
Arthur Cohen 143aad62e1 substitute_repetition: Add parsing of repetition pattern 2022-02-22 12:05:58 +01:00
Arthur Cohen ae1f91a698 transcribe: Move substitute_metavar in its own function 2022-02-22 11:57:19 +01:00
bors[bot] 265c223766
Merge #964 #965
964: Forbid unresolved test cases r=CohenArthur a=CohenArthur

Closes #923 

965: macro-invoc-lexer: Split implementation in its own file r=CohenArthur a=CohenArthur

Closes #949 

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-22 10:05:34 +00:00
bors[bot] 133beb6d0f
Merge #955
955: matched_fragment: Track and set fragment match amount r=CohenArthur a=CohenArthur



Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-22 09:39:25 +00:00
Arthur Cohen 91aca2c19e matched_fragment: Track and set fragment match amount
Co-authored-by: philberty <philip.herron@embecosm.com>
2022-02-22 10:38:39 +01:00
Arthur Cohen 4e19c2f792 macro-invoc-lexer: Split implementation in its own file 2022-02-21 17:27:56 +01:00
Arthur Cohen 9b36f95366 testsuite: Add -fdump-tree-gimple to inline1.rs 2022-02-21 17:01:10 +01:00
Arthur Cohen 737873ca87 ci: Do not allow unresolved test cases 2022-02-21 16:39:06 +01:00
bors[bot] 796465596f
Merge #950
950: Match macro repetitions r=CohenArthur a=CohenArthur

This PR adds support for matching macro invocations and counting the amount of times they've been matched

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-20 14:34:37 +00:00
bors[bot] 4e096b1f14
Merge #951
951: Add name resolution to slices r=philberty a=philberty

This is the first part to support slices where we complete the name
resolution of the SliceType with its element as well as the range
expressions used in construction.

This patch also includes separation of the implementation from the
headers to try and incrementally improve build speed.

Addresses #849 

Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-02-20 14:03:54 +00:00
Arthur Cohen d0d4dcfdb4 macro: Add repetition execution test cases 2022-02-18 16:46:10 +01:00
Arthur Cohen af789a7079 macros: Add test cases for repetitions 2022-02-18 16:46:10 +01:00
Arthur Cohen ad7e4bb6f8 macro-repetitions: Match repetitions properly 2022-02-18 16:46:10 +01:00
bors[bot] 31387e7609
Merge #944
944: parser: Add `clear_errors()` method r=CohenArthur a=CohenArthur

Clears all errors from the error table so we can reuse the parser in later situations. I'm unsure whether or not the method should also emit all of the errors if present? In that case, we might want to rename it or add another wrapper that emits then clears

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-18 14:43:08 +00:00
Philip Herron 3dd4ce76a6 Add name resolution to range expressions 2022-02-18 13:26:24 +00:00
Philip Herron 755d0e5adf Refactor AST::ResolveExpr into its own cc file 2022-02-18 13:07:13 +00:00
Philip Herron de08987dc7 Add name resolution to AST::SliceType 2022-02-18 12:55:14 +00:00
Philip Herron 78cdc6ca31 Refactor type name resolution into their own .cc file 2022-02-18 12:46:44 +00:00
bors[bot] 425905b49a
Merge #942
942:  Removed Lambda Function within AST::PathPattern r=philberty a=mvvsmk

Addresses issue #717 
1) Changed the rust-path.h and removed the iterate_path_segments
   fuction.
2) Removed the lambda fuction form rust-ast-lower.cc and replaced it
   with a for loop.

Do let me know if I missed anything or could improve on something.

Signed-off-by : M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>



Co-authored-by: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
2022-02-18 11:50:32 +00:00
Arthur Cohen 472c0a3057 macro-repetition: Rename enum variants to better reflect repetition kind 2022-02-18 11:18:03 +01:00
Arthur Cohen 5f35a8c637 parser: Add `clear_errors()` method 2022-02-18 09:19:04 +01:00
bors[bot] fbe22e8768
Merge #940
940: Add more location info to AST structures r=CohenArthur a=CohenArthur

Two classes still remain locus-less: `TupleStructItems` and `TuplePatternItems` as I do not believe they are constructed at the moment.

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-18 08:14:30 +00:00
Arthur Cohen 0e15b89839 struct pattern: Add location on struct name 2022-02-18 09:10:55 +01:00
Arthur Cohen 425ebda243 type-path-fn: Add location info on start of Fn token 2022-02-18 09:10:52 +01:00
Arthur Cohen ef06769781 path-id: Add location info on path identifier 2022-02-18 09:08:07 +01:00
Arthur Cohen 9e524a7f5a closure-arg: Add location info on arg name 2022-02-18 09:08:07 +01:00
Arthur Cohen 63538444fb struct-base: Add location info on `..` token 2022-02-18 09:08:07 +01:00
Arthur Cohen d120c9db18 array-copy-init: Add location info 2022-02-18 09:08:07 +01:00
Arthur Cohen c6daece647 array-values: Add location info 2022-02-18 09:08:07 +01:00
Arthur Cohen 205a9cbf9e fn-arg: Add location on parameter name 2022-02-18 09:08:07 +01:00
bors[bot] 9fb06d66ce
Merge #938
938: First pass at declarative macro expansion  r=philberty a=philberty

This does not support repetition matchers but it supports simple
declarative macros and transcribes them. The approach taken here is that
we reuse our existing parser to call the apropriate functions as specified
as part of the MacroFragmentType enum if the parser does not have errors
parsing that item then it must be a match.
    
Then once we match a rule we have a map of the token begin/end offsets
for each fragment match, this is then used to adjust and create a new token
stream for the macro rule definition so that when we feed it to the parser
the tokens are already substituted. The resulting expression or item is
then attached to the respective macro invocation and this is then name
resolved and used for hir lowering.
    
Fixes #17 #22
Addresses #573

Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-02-17 17:02:43 +00:00
M V V S Manoj Kumar ee4131396e Removed Lambda Function within AST::PathPattern
Addresses issue #717
1) Changed the rust-path.h and removed the iterate_path_segments
   fuction.
2) Removed the lambda fuction form rust-ast-lower.cc and replaced it
   with a for loop.

Signed-off-by : M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
2022-02-17 22:11:23 +05:30
Philip Herron 37415eec77 Semicolon based macro invocation
This allows for macro invocation at the toplevel or as statements. This
patched required us to propogate the delimited token tree fix to include
the delimiter tokens. The rest of the fix was straight forward to call
the apropriate visitors in names resolution and hir lowering.

Some thought will be needed to handle hir lowering for repeating items.
2022-02-17 16:41:15 +00:00
Philip Herron 4c70d7ec77 Support block expressions within macros
When we parse DelimTokenTree's the delimiter's are synthesised when we
ask for the token stream which results in tokens lacking location info.
This removes the hack by adding the actual tokens from the lexer into the
stream.
2022-02-17 13:28:25 +00:00
Philip Herron 19c5dde80f When we expand a macro we must visit it to ensure any cfg expansions or recursive macro expansion is required 2022-02-17 13:28:25 +00:00
Philip Herron 2c03f34027 Add initial support for macro expansion
This is the first pass at implementing macros more testcases are needed.

This does not support repetition matchers but it supports simple
declarative macros and transcribes them. The approach taken here is that
we reuse our existing parser to call the apropriate functions as specified
as part of the MacroFragmentType enum if the parser does not have errors
parsing that item then it must be a match.

Then once we match a rule we have a map of the token begin/end offsets
for each fragment match, this is then used to adjust and create a new token
stream for the macro rule definition so that when we feed it to the parser
the tokens are already substituted. The resulting expression or item is
then attached to the respective macro invocation and this is then name
resolved and used for hir lowering.

Fixes #17 #22
Addresses #573
2022-02-17 13:28:25 +00:00
Philip Herron ef626302f7 Add name-resolution helpers for looking up macros 2022-02-17 13:28:24 +00:00
Philip Herron a026c166f0 Add mappings helpers for looking up macros definitions 2022-02-17 13:28:24 +00:00
Philip Herron 864df7901c Add missing copyright header to lexer header 2022-02-17 13:28:24 +00:00
bors[bot] 752bf6c80a
Merge #935
935: frust-cfg: Only allow double quoted values r=philberty a=CohenArthur

Closes #910 

This PR separates the `handle_cfg_option()` function in two, separating the parsing logic from the session logic. The parsing logic is able to be unit tested, and now only allows quoted values.

What remains to be done is to only allow `key` and `value` to be proper rust identifiers. We need to figure out if we'd like to spawn a parser here and parse identifiers, or simply sanitize both strings to make sure they do not contain invalid characters.

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-17 10:58:07 +00:00
Arthur Cohen 766a9002a3 frust-cfg: Only allow double quoted values
This commit separates the `handle_cfg_option()` function in two,
separating the parsing logic from the session logic. The parsing logic
is able to be unit tested, and now only allows quoted values.
2022-02-17 11:23:25 +01:00
bors[bot] 6a6c217093
Merge #932
932: Add location information to MacroRule r=CohenArthur a=CohenArthur

Closes #930 

This PR adds location information to the `MacroRule` structure.

The location is from the beginning of the invokation pattern, so that errors look like so:
```rust
test.rs:2:5: error: ...
    2 |     ($a:expr, $b:expr) => { a + b }
      |     ^
```

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-17 09:22:03 +00:00
Arthur Cohen c1e72db48a macrorule: Add location information 2022-02-17 10:20:13 +01:00
bors[bot] d81ba63f48
Merge #933
933: macrotranscriber: Add location info r=CohenArthur a=CohenArthur

Closes #929 

Adds location info to the macro's transcriber. When generating a `MacroRule` error, this PR creates an empty location for the transcriber, since the error function is only called if no fat arrow is present or if there was an error parsing the macro's matcher. Please let me know if this is the expected behavior

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-17 08:44:36 +00:00
Arthur Cohen 45ca46018f macrotranscriber: Add location info 2022-02-17 09:43:48 +01:00
bors[bot] a5272f389b
Merge #934 #937
934: macromatch: Add location to abstract MacroMatch class r=philberty a=CohenArthur

Closes #928 

This adds location to the all child classes of the `MacroMatch` abstract class. The current locations are as follow, which I believe is what is expected but might be wrong.

```rust
test.rs:2:6: error: macro match fragment
    2 |     ($a:expr, $b:expr) => { $a + $b };
      |      ^
test.rs:2:15: error: macro match fragment
    2 |     ($a:expr, $b:expr) => { $a + $b };
      |               ^
test.rs:2:5: error: macro matcher
    2 |     ($a:expr, $b:expr) => { $a + $b };
      |     ^
test.rs:3:8: error: macro match fragment
    3 |     ($($i:ident)*) => { $($i)* }
      |        ^
test.rs:3:17: error: macro match repetition!
    3 |     ($($i:ident)*) => { $($i)* }
      |                 ^
test.rs:3:5: error: macro matcher
    3 |     ($($i:ident)*) => { $($i)* }
      |     ^
```

I think this should be rebased on #932 so that I can remove the FIXME 

937: dockerfile: Install cargo-gccrs alongside gccrs r=philberty a=CohenArthur

Closes #826 

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-16 18:38:44 +00:00
bors[bot] 733db624cf
Merge #931
931: rust-cfg: Quote option name when erroring out r=philberty a=CohenArthur

Removes a warning generated by `-Wformat-diag`

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-16 18:13:03 +00:00
Arthur Cohen 85d78c1b8d dockerfile: Install cargo-gccrs alongside gccrs 2022-02-16 18:47:36 +01:00