Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Getting Started text #111

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/src/get_started.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting Started

You can either paste this code into the Julia REPL or into a seperate file, e.g. `get_started.jl` followed by `julia get_started.jl`.
You can either paste this code into the Julia REPL or into a seperate file, e.g. `get_started.jl`. If using a separate file you can execute using `julia get_started.jl` or `julia --project=. get_started.jl` depending on whether you installed Herb.jl globally or in a project.

To begin, we need to import all needed packages using

Expand Down Expand Up @@ -33,7 +33,7 @@ problem = Problem([IOExample(Dict(:x => x), 2x+1) for x ∈ 1:5])
The problem is given now, let us search for a solution with `HerbSearch`. For now we will just use the default parameters searching for a satisfying program over the grammar, given the problem and a starting symbol using

```julia
iterator = BFSIterator(g, :Number, max_depth=5)
iterator = BFSIterator(g, :Number, max_depth=5)
solution, flag = synth(problem, iterator)
println(solution)
```
Expand All @@ -44,11 +44,14 @@ Eventually, we want to test our solution on some other inputs using `HerbInterpr

```julia
program = rulenode2expr(solution, g) # should yield 2*6+1
println(program)

output = execute_on_input(SymbolTable(g), program, Dict(:x => 6))
println(output)
```

If you run the completed code it will output both the generated Julia expression and the result from assigning value.

Just like that we tackled (almost) all modules of Herb.jl.

## Where to go from here?
Expand All @@ -70,10 +73,11 @@ g = @csgrammar begin
end

problem = Problem([IOExample(Dict(:x => x), 2x+1) for x ∈ 1:5])
iterator = BFSIterator(g, :Number, max_depth=5)
iterator = BFSIterator(g, :Number, max_depth=5)

solution, flag = synth(problem, iterator)
program = rulenode2expr(solution, g) # should yield 2*6 +1
println(program)

output = execute_on_input(SymbolTable(g), program, Dict(:x => 6))
println(output)
Expand Down
Loading