Comments (5)
This is a good idea, but it's going to be really hard. Locations will have to be expanded to keep track of each macro along the way, which means they can no longer be Copy
and there will suddenly be a lot of lifetime errors.
Maybe there should be some sort of lookup table for locations so that they don't have to be passed along with each struct? I don't think HashMap<dyn Hash, Location>
is a thing, though.
from saltwater.
The Location
s of #define
s are stored in a map somewhere already, I assume? So could we instead add an Option<InternedStr>
member to Token::Id
which points to where it which macro replaced into it? Then if there's an error, we can do a recursive lookup until None
.
from saltwater.
Or if the Location
s of #define
s aren't already stored somewhere, then lex::replace::Definitions
could be changed from
pub type Definitions = HashMap<InternedStr, Definition>;
to
pub type Definitions = HashMap<InternedStr, (Definition, Location)>;
Not sure if this will mess with lifetimes.
from saltwater.
@hdamron17 sure, making it a HashMap<InternedStr, Locatable<Definition>>
isn't hard. The hard part is tracing back from the replaced version to the original. By the time this error occurs in the parser, all context about macros has been lost, there's only tokens left and you can't tell if they originated from a macro or not.
from saltwater.
I guess a linked list isn't the worst thing since most replacements shouldn't be highly nested. I'm a little concerned about memory usage but we can always worry about performance later.
from saltwater.
Related Issues (20)
- Space between function macro name and args HOT 2
- Do not report type error when one type is "<type error>" HOT 1
- Cross-check rcc against other compilers HOT 3
- Incomplete function macro call should be an error
- [ICE] bug in parser: loaded a variable that was not declared HOT 1
- Get rid of unput in lexer HOT 1
- Get rid of seen_line_token
- Hexadecimal floating constant requires an exponent HOT 3
- Optional whitespace between command line argument key and value HOT 1
- [ICE] Newline in string
- [ICE] Macro expansion assertion failed HOT 3
- Add tests for command line arguments HOT 4
- Link object files when passed in instead of source files
- Pre-increment on pointer to struct causes error
- Generate man pages using help2man HOT 4
- ## is not implemented HOT 10
- Switch from shared_str to arcstr
- The order of preprocessor stringifying is wrong. HOT 1
- ArgumentExtension is not set for AbiParam
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from saltwater.