redstarbird / redstarbird/ArrowCSS
Add helper functions for working with ASTs
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Node creation
ArrowCSS_CreateDeclaration(ast, property, value) for creating a declaration with a property-value pair
ArrowCSS_CreateAtRule to create an at-rule
ArrowCSS_CreateRuleset(ast, selector) for creating a ruleset with a specific selector.
ArrowCSS_CloneNode to to clone an ASTNode struct along with all of its children.
Tree modification
To append a child to a node, ArrowCSS_AppendChild can be used which will validate the passed nodes and add the child node to the linked list of children under the parent node.
To add a child after another child in a linked list, ArrowCSS_InsertAfter(target, newNode) which will insert the newNode after the target node as a child of the parent node.
To add a child before another child in a linked list of children, ArrowCSS_InsertBefore(parent, target,newNode) which will insert the newNode before the target node as a child of the parent node.
To remove a child node, ArrowCSS_RemoveChild(ast, child) will remove the provided child node from the ast and will return the removed child node to the caller.
Traversal
Traversal: ArrowCSS_Walk(root, callback, userData) which will allow the user to traverse the tree using a custom callback function for each node as well as being able to pass their own data such as state or config
Search/query
Get declaration from block: ArrowCSS_GetDeclaration(ruleset, propertyName) to find and return the declaration with the given property name within the block or NULL if the declaration is not found.
Check if a selector is present for a ruleset: ArrowCSS_GetSelector(ruleset, selector) to check if a specific selector exists within the selector for a ruleset.
String view helper functions
Equals: ArrowCSS_ViewEquals(view,string) efficiently compares whether a string is the same as the string within a string view.
Starts with: ArrowCSS_ViewStartsWith(view, string) checks whether a string view starts with a substring
Contains: ArrowCSS_ViewContains(view,string) checks whether a string view contains a substring
Update: ArrowCSS_ViewUpdate(ast, targetView, string) updates a string view to contain a new string as string views cannot be directly modified
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the ASTNode structure, its child linked-list representation, and the existing string-view utilities. Then trace how nodes are created and freed before planning the requested creation, cloning, tree-editing, traversal, query, and view helpers. Done means each listed ArrowCSS helper is implemented with the stated behavior and validated by the project's existing checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100