diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-05-06T16·46+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-05-06T16·46+0000 |
commit | 84ce7ac76feab6e9a5c074bd1b9550ae543d1db8 (patch) | |
tree | 6fe85234390d62dd3e712cf2169d0963e4e87af2 /src/libexpr/nixexpr.hh | |
parent | c82782f9a5190c7489fb8e9bd6876b247b0de0bf (diff) |
* Store attribute positions in the AST and report duplicate attribute
errors with position info. * For all positions, use the position of the first character of the first token, rather than the last character of the first token plus one.
Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r-- | src/libexpr/nixexpr.hh | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index 2d328d382c8d..36cb4e53cd7c 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -23,8 +23,13 @@ struct Pos { string file; unsigned int line, column; + Pos() : line(0), column(0) { }; + Pos(const string & file, unsigned int line, unsigned int column) + : file(file), line(line), column(column) { }; }; +extern Pos noPos; + std::ostream & operator << (std::ostream & str, const Pos & pos); @@ -125,10 +130,11 @@ struct ExprOpHasAttr : Expr struct ExprAttrs : Expr { bool recursive; - typedef std::map<Symbol, Expr *> Attrs; + typedef std::pair<Expr *, Pos> Attr; + typedef std::map<Symbol, Attr> Attrs; Attrs attrs; list<VarRef> inherited; - set<Symbol> attrNames; // used during parsing + std::map<Symbol, Pos> attrNames; // used during parsing ExprAttrs() : recursive(false) { }; COMMON_METHODS }; |