Skip to content

Commit

Permalink
expand README
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldo committed Jan 8, 2021
1 parent 581692d commit 1b16e45
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,23 @@ A PHP library for the [KDL Document Language](https://github.com/kdl-org/kdl).

For now, this library only supports parsing.

Parsing is slow for now - for example, parsing a 45 line file with a tree depth of 5 is likely to take 250-300ms. This library favours correctness over performance - however, the aim is to optimise the parsing to a point of reasonable speed.

The parser uses [Parsica](https://parsica.verraes.net/) as an underlying parsing library in order to map fairly directly and clearly onto the published KDL grammar - Parsica uses FP principles, and one result of this is that the call stack depth used during parsing may be high. Be warned if you are using e.g. xdebug, as parsing may exceed any normal maximum stack depth that you may set.

## Examples

```php
$data = Shieldo\Kdl\Kdl::parse($kdlString);
$document = Shieldo\Kdl\Kdl::parse($kdlString);
foreach ($document as $node) {
$node->getName(); //gets the name for the node @see https://github.com/kdl-org/kdl/blob/main/SPEC.md#node
$node->getValues(); //gets a list of values for a node @see https://github.com/kdl-org/kdl/blob/main/SPEC.md#value
$node->getProperties(); //gets an associative array of properties @see https://github.com/kdl-org/kdl/blob/main/SPEC.md#property
foreach ($node->getChildren() as $child) {
$child->getName(); //name for the child
//etc
}
}
```

## License
Expand Down

0 comments on commit 1b16e45

Please sign in to comment.