diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2018-10-26 17:44:33 +0200 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2018-11-13 15:29:27 +1100 |
commit | baa1d2cf7894a32bf2f640ef40ebce561b2df565 (patch) | |
tree | 375454c91eef6ff64df067a1aef86896ae7dd09e /srcpos.h | |
parent | ff2ad38f6a5a87603c519096fd7066082c4c6f75 (diff) | |
download | dtc-baa1d2cf7894a32bf2f640ef40ebce561b2df565.zip dtc-baa1d2cf7894a32bf2f640ef40ebce561b2df565.tar.gz dtc-baa1d2cf7894a32bf2f640ef40ebce561b2df565.tar.bz2 |
annotations: add positions
Extend the parser to record positions, in build_node, build_node_delete,
and build_property.
srcpos structures are added to the property and node types, and to the
parameter lists of the above functions that construct these types.
Nodes and properties that are created by the compiler rather than from
parsing source code have NULL as the srcpos value.
merge_nodes, defined in livetree.c, uses srcpos_extend to combine
multiple positions, resulting in a list of positions. srcpos_extend is
defined in srcpos.c. New elements are added at the end. The srcpos
type, define in srcpos.h, is now a list structure with a next field.
Another change to srcpos.c is to make srcpos_copy always do a full copy,
including a copy of the file substructure. This is required because
when dtc is used on the output of cpp, the successive detected file
names overwrite the file name in the file structure. The next field
does not need to be deep copied, because it is only updated in newly
copied positions and the positions to which it points have also been
copied. File names are only updated in uncopied position structures.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'srcpos.h')
-rw-r--r-- | srcpos.h | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -74,6 +74,7 @@ struct srcpos { int last_line; int last_column; struct srcfile_state *file; + struct srcpos *next; }; #define YYLTYPE struct srcpos @@ -105,6 +106,8 @@ extern struct srcpos srcpos_empty; extern void srcpos_update(struct srcpos *pos, const char *text, int len); extern struct srcpos *srcpos_copy(struct srcpos *pos); +extern struct srcpos *srcpos_extend(struct srcpos *new_srcpos, + struct srcpos *old_srcpos); extern char *srcpos_string(struct srcpos *pos); extern void PRINTF(3, 0) srcpos_verror(struct srcpos *pos, const char *prefix, |