Top | ![]() |
![]() |
![]() |
![]() |
A AnjutaToken represents a token. It is a sequence of characters associated with a type representing its meaning. By example, a token can represent a keyword, a comment, a variable...
The token can own the string or has only a pointer on some data allocated somewhere else with a length.
A token is linked with other tokens using three double linked lists.
The first list using next and prev fields is used to keep the token in the order where there are in the file. The first character of the first token is the first character in the file.
A second list is used to represent included files. Such file is represented by a special token in the first list which has a pointer, named children to a token list. Each token in this secondary list has a pointer to its parent, it means the token representing the file where is the token. It looks like a tree. In fact, every file is represented by a special token, so the root node is normally a file token and has as children all the token representing the file content. This parent/child list is used for expanded variable too.
A third list is used to group several tokens. A token can have a pointer to another last token. It means that this token is a group starting from this token to the one indicated by the last field. In addition each token in this group has a pointer on the first token of the group. This grouping is independent of the parent/child list. So a group can start in one file and end in another included file. The grouping can be nested too. Typically we can have a group representing a command, a sub group representing the arguments and then one sub group for each argument.
AnjutaToken * anjuta_token_new_string (AnjutaTokenType type
,const gchar *value
);
AnjutaToken * anjuta_token_new_string_len (AnjutaTokenType type
,gchar *value
,gsize length
);
AnjutaToken * anjuta_token_new_static (AnjutaTokenType type
,const gchar *value
);
AnjutaToken * anjuta_token_new_static_len (gint type
,const gchar *pos
,gsize length
);
void anjuta_token_set_string (AnjutaToken *token
,const char *value
,gsize length
);
AnjutaToken *
anjuta_token_next_after_children (AnjutaToken *token
);
void anjuta_token_foreach_content (AnjutaToken *token
,AnjutaTokenForeachFunc func
,gpointer user_data
);
void anjuta_token_foreach_token (AnjutaToken *token
,AnjutaTokenForeachFunc func
,gpointer user_data
);
AnjutaToken * anjuta_token_foreach_post_order (AnjutaToken *token
,AnjutaTokenForeachFunc func
,gpointer user_data
);
AnjutaToken * anjuta_token_append_child (AnjutaToken *parent
,AnjutaToken *children
);
Insert all tokens in children as the last children of the given parent.
AnjutaToken * anjuta_token_prepend_child (AnjutaToken *parent
,AnjutaToken *children
);
Insert all tokens in children as the first children of the given parent.
AnjutaToken * anjuta_token_prepend_items (AnjutaToken *list
,AnjutaToken *item
);
Insert all tokens in item as item of the given list.
AnjutaToken * anjuta_token_insert_after (AnjutaToken *sibling
,AnjutaToken *list
);
Insert all tokens after sibling.
AnjutaToken * anjuta_token_insert_before (AnjutaToken *sibling
,AnjutaToken *list
);
Insert all tokens before sibling.
AnjutaToken *
anjuta_token_delete_parent (AnjutaToken *parent
);
Delete only the parent token.
AnjutaToken *
anjuta_token_merge_own_children (AnjutaToken *first
);
AnjutaToken * anjuta_token_merge_children (AnjutaToken *first
,AnjutaToken *end
);
AnjutaToken * anjuta_token_merge_previous (AnjutaToken *list
,AnjutaToken *first
);
If the list token is not already linked with first, it is inserted just before first. If the list token is already linked, it must be in the same list after first token. It it possible to have several tokens beweent list and first.