Skip to content

Commit

Permalink
modified doc
Browse files Browse the repository at this point in the history
  • Loading branch information
aiq committed Mar 20, 2022
1 parent 5760c21 commit 4ad7ef2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
22 changes: 14 additions & 8 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The package has the following read functions:

Readers can be used by the scanner to read from the scanner.
tok has the following build-in Reader:
Any, AnyRune, Between, BetweenAny, Bool, Digit, Fold, Holey, Int, Lit, Map, Match, Opt, Rune, Seq, Times, To, Uint, Wrap, WS, Zom
Any, AnyFold, AnyRune, At, Between, BetweenAny, Body, Bool, Digit, Fold, Hex, Holey, Int, Janus, Lit, Many, Map, Match, Named, Not, Opt, Past, Rune, Seq, Set, SkipSeq, SkipWSSeq, Times, To, Uint, Wrap, WS, Zom


== Mark Types
Expand All @@ -40,16 +40,13 @@ can be used to mark a scanner position
Token::
can be used to mark a range of the scanner

Value::
can be used tag a Token with addition information

Segment::
groups a value with the corresponding sub string
can be used tag a Token with addition information

== Grammar

A grammar is a Reader that has RuleReader that are connected.
Check the grammar for JSON in the gramar package.
A grammar is a Reader that has connected Rules.
Check the grammar package with different grammars, like JSOM, MXT and Lua.

== Graph

Expand All @@ -59,4 +56,13 @@ With the FlameStack function is it possible to generate a string that can be use
[source,shell]
----
$ flamegraph.pl flame.stack > graph.svg
----
----

== Tracker

A Tracker can be coupled with a Scannar and track the movemend.
Basket is a Tracker und can be used to Pick-Up Elements that where read by the Parser.

== Log

A Log can be used to monitor and log the movemend in a Reader graph.
8 changes: 6 additions & 2 deletions tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ import (
"strings"
)

// Tracker
// Tracker is an interface that can be coupled with a Scannar and track the movemend.
type Tracker interface {
Update(m Marker)
}

// Returns a new empty Basket that is set as Tracker on the scanner.
// Returns a new empty Basket that is coupled as Tracker on the scanner.
func (s *Scanner) NewBasket() *Basket {
b := &Basket{}
s.Tracker = b
return b
}

// Returns a new empty Basket that is coupled as Tracker on the scanner.
// Each Rule that matches picks the Segment to the Basket.
func (s *Scanner) NewBasketFor(g Grammar) *Basket {
b := &Basket{}
b.PickWith(g.Grammar()...)
Expand All @@ -30,6 +32,7 @@ type Basket struct {
segments []Segment
}

// Add adds a Segment to the Basket.
func (b *Basket) Add(seg Segment) {
b.segments = append(b.segments, seg)
}
Expand All @@ -45,6 +48,7 @@ func (b *Basket) Update(m Marker) {
b.segments = []Segment{}
}

// Picked returns the picked Segments.
func (b *Basket) Picked() []Segment {
return b.segments
}
Expand Down

0 comments on commit 4ad7ef2

Please sign in to comment.