The esrap-liquid Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The esrap-liquid Reference Manual

This is the esrap-liquid Reference Manual, version 2.3, generated automatically by Declt version 4.0 beta 2 "William Riker" on Thu Sep 15 04:41:42 2022 GMT+0.

Table of Contents


1 Introduction

ESRAP-LIQUID

MAJOR API CHANGE IN VERSIONS 2.*: we no longer use codewalker, hence rule definitions now compile much faster. The price to pay is that sometimes you need to specify manually, that something is a sub-rule (see V-macrolet in source and section "API Change" in this README).

Packrat parser generator, with possibility to use full Common Lisp when defining parsing rules.

It started as a fork of ESRAP by Nikodemus Siivola (https://github.com/nikodemus/esrap), which is a DSL with (somewhat) more rigid syntax, but (as of now) nicer error reports.

Original idea of a packrat parser generator is described in this article:

Operates both on strings and streams -- see section "Streaming" below.

Examples:

; plain characters match to precisely that character in text
ESRAP-LIQUID> (parse '#\a "a")
#\a
1
ESRAP-LIQUID> (parse '#\a "b")
#<ESRAP-LIQUID::SIMPLE-ESRAP-ERROR "~a~%">.
; same goes for plain strings
ESRAP-LIQUID> (parse '"foo" "foo")
"foo"
3
ESRAP-LIQUID> (parse '"foo" "bar")
#<ESRAP-LIQUID::SIMPLE-ESRAP-ERROR "~a~%">.
; CHARACTER matches any single character
ESRAP-LIQUID> (parse 'character "a")
#\a
1
ESRAP-LIQUID> (parse 'character "b")
#\b
1
; (ANY-STRING <LENGTH>) matches any string of a given length character
ESRAP-LIQUID> (parse '(any-string 3) "foo")
"foo"
3
ESRAP-LIQUID> (parse '(any-string 3) "bar")
"bar"
3
ESRAP-LIQUID> (parse '(any-string 3) "caboom!")
#<ESRAP-LIQUID::SIMPLE-ESRAP-ERROR "~a~%">.
; (!! <EXPR>) matches, whenever EXPR fails and consumes one character
ESRAP-LIQUID> (parse '(!! "foo") "bar" :junk-allowed t)
#\b
1
ESRAP-LIQUID> (parse '(!! "foo") "foo")
#<ESRAP-LIQUID::SIMPLE-ESRAP-ERROR "~a~%">.
; (|| &rest <EXPRS>) is an ordered choice, matches, whenever one of EXPRS succeeds, and outputs it
ESRAP-LIQUID> (parse '(|| #\a #\b) "a")
#\a
1
ESRAP-LIQUID> (parse '(|| #\a #\b) "b")
#\b
1
ESRAP-LIQUID> (parse '(|| #\a #\b) "c")
#<ESRAP-LIQUID::SIMPLE-ESRAP-ERROR "~a~%">.
; (times <EXPR> &key from upto exactly) greedy matches expression multiple times, returns values as a list.
; If :UPTO or :EXACTLY is given, then consumes only that much exprs, even if there are more
; if :FROM is given, fails if consumed less than :FROM expressions
ESRAP-LIQUID> (parse '(times #\a) "")
NIL
0
ESRAP-LIQUID> (parse '(times #\a) "aaa")
(#\a #\a #\a)
3
ESRAP-LIQUID> (parse '(times #\a :exactly 6) "aaaaaa")
(#\a #\a #\a #\a #\a #\a)
6
ESRAP-LIQUID> (parse '(times #\a :exactly 6) "aaa")
#<ESRAP-LIQUID::SIMPLE-ESRAP-ERROR "~a~%">.
; (postimes <EXPR>) is an alias for (times <EXPR> :from 1)
ESRAP-LIQUID> (parse '(postimes #\a) "")
#<ESRAP-LIQUID::SIMPLE-ESRAP-ERROR "~a~%">.
ESRAP-LIQUID> (parse '(postimes #\a) "aaa")
(#\a #\a #\a)
3
; (? <EXPR>) returns result of parsing of EXPR, when parsing succeeds, and NIL otherwise, does not fail
ESRAP-LIQUID> (parse '(? #\a) "")
NIL
0
ESRAP-LIQUID> (parse '(? #\a) "a")
#\a
1

Other operators, defined by ESRAP-LIQUID, include:

Typical idioms:

; succeed, when all subexpressions succeed, return list of those subexpressions
; Note that now you need to explicitly write (V ...) in order to indicate that
; character means "try to parse this character"
ESRAP-LIQUID> (parse '(list (v #\a) (v #\b) (v #\c)) "abc")
(#\a #\b #\c)
3
; succeed, when all subexpression succeed, return only last subexpression
ESRAP-LIQUID> (parse '(progn (v #\a) (v #\b) (v #\c)) "abc")
#\c
3
; succeed, when all subexpression succeed, return only first subexpression
ESRAP-LIQUID> (parse '(prog1 (v #\a) (v #\b) (v #\c)) "abc")
#\a
3

For more examples, see example-sexp.lisp, example-symbol-table.lisp, example-very-context-sensitive.lisp. For more real-life examples see my YAML parser https://github.com/mabragor/cl-yaclyaml. The parsing part uses ESRAP-LIQUID extensively, in particular, in ways different from traditional ESRAP.

Defining rules

Of course, if you could only write one-liners with PARSE, it won't be interesting at all So, you can define new rules using DEFRULE macro.

ESRAP-LIQUID> (defrule foo+ ()
                (postimes "foo"))
ESRAP-LIQUID> (parse 'foo+ "foofoofoo")
("foo" "foo" "foo")
; simple arguments to rules are also possible
ESRAP-LIQUID> (defrule foo-times (times)
                (times "foo" :exactly times))
ESRAP-LIQUID> (parse '(v foo-times 3) "foofoofoo")
("foo" "foo" "foo")
ESRAP-LIQUID> (parse '(v foo-times 4) "foofoofoo")
#<ESRAP-LIQUID::SIMPLE-ESRAP-ERROR "~a~%">.

Defining esrap-environments

Usually you don't want to mix parsing rules for different projects -- you want a mechanism to scope your rules in some way. For that you can use DEFINE-ESRAP-ENV macro.

(define-esrap-env foobar)

;; Now we can define rules in 'foobar' scope
(define-foobar-rule asdf ()
   ... ; rule definition here)

DEFINE-ESRAP-ENV has a MAINLY-NON-CONTEXT key. If it's T, then DEFINE-$(NAME)-RULE expands into DEF-NOCONTEXT-RULE, rather than DEFRULE. It's still possible to get context-sensitive rules by using DEFINE-C-$(NAME)-RULE. Vice versa, if MAINLY-NON-CONTEXT key is NIL (default), then non-context-sensitive rules can be defined using DEFINE-NC-$(NAME)-RULE.

Capturing-variables : CAP, RECAP, RECAP?

Analogously to capturing groups in regexps, it is possible to capture results of parsing of named rules, to aid destructuring.

Example: instead of clumsy

(define-rule dressed-rule-clumsy ()
  (prog1 (progn (v "foo") (v "bar") (v "baz")
                (v meat))
         (v "rest1") (v "rest2") (v "rest3")))

you may write something like

(define-rule dressed-rule-elegant ()
  (v "foo") (v "bar") (v "baz") (cap 1 meat) (v "rest1") (v "rest2") (v "rest3")
  (recap 1))

I.e. result of parsing of rule with name MEAT is stashed with CAP macro and then accessed using RECAP macro.

Difference between RECAP and RECAP? is that while the former fails parsing if the requested key was not captured, the latter just produces NIL.

See tests for examples of usage. Also see CL-MIZAR parsing.lisp, where this is used a lot.

Streaming

It's possible to parse both strings and streams. Main function for parsing streams is PARSE-STREAM.

Example of usage:

(parse-stream 'some-rule (make-string-input-stream "foobar") :junk-allowed t)

In general, both PARSE and PARSE-STREAMS are just wrappers around more general PARSE-TOKEN-ITER -- which accepts an iterator of tokens. Here, iterators are implemented "pythonic way", i.e. they are classes with NEXT-ITER method (the next method in Python), that throw STOP-ITERATION condition (the StopIteration exception in Python) when there are no more values.

Thus, if you want ESRAP-LIQUID to parse something other than string or stream, just grep for how PARSE-TOKEN-ITER is used.

Change : PARSE-TOKEN-ITER now wraps the iterator into esrap caching iterator, so you don't have to do it manually. Also now ESRAP-ENV makes $(ENVNAME)-PARSE-TOKEN-ITER function accessible.

Gotchas!

-- Since Lisp streams only allow to unread one character, and ESRAP-LIQUID in general does quite a lot of look-ahead, it's not safe to use a stream somewhere else after it was fed to PARSE-STREAM (even when :junk-allowed is set to T). This is because you don't know, what state the stream ends up in.

When you define esrap environment using DEFINE-ESRAP-ENV, say, like

(define-esrap-env foo)

you get both FOO-PARSE and FOO-PARSE-STREAM -- environment versions of main parsing functions.

API Change

In versions 1.* of ESRAP-LIQUID, we used the following implicit conventions, when defining rules:

These conventions are very handy when defining rules. However, the way they were implemented, is not optimal:

So now these conventions are not valid in the whole scope of DEFRULE, but only inside special macrolets. This allowed not to depend on codewalker and on special reader conventions. Now conventions are like this:

Update: it turned out that in practice one most commonly uses V-macrolet inside PROGN, LIST and PROG1 forms. So now ESRAP-LIQUID defines PROGN-V, LIST-V and PROG1-V versions, which work exactly as their non-V analogs, but wrap their sub-forms in DESCEND-WITH-RULE, where needed.

Thus, to make a transition of your ESRAP-LIQUID-using code to 2.* API, you need:


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 esrap-liquid

A Packrat / Parsing Grammar / TDPL parser for Common Lisp.

License

GPL

Version

2.3

Dependencies
  • alexandria (system).
  • iterate (system).
  • cl-ppcre (system).
  • cl-interpol (system).
Source

esrap-liquid.asd.

Child Components

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 esrap-liquid/src

Source

esrap-liquid.asd.

Parent Component

esrap-liquid (system).

Child Components

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Next: , Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

4.1.1 esrap-liquid/esrap-liquid.asd

Source

esrap-liquid.asd.

Parent Component

esrap-liquid (system).

ASDF Systems

esrap-liquid.

Packages

esrap-liquid-system.


4.1.2 esrap-liquid/src/package.lisp

Source

esrap-liquid.asd.

Parent Component

src (module).

Packages

esrap-liquid.


4.1.3 esrap-liquid/src/conditions.lisp

Dependency

package.lisp (file).

Source

esrap-liquid.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.4 esrap-liquid/src/miscellany.lisp

Dependency

conditions.lisp (file).

Source

esrap-liquid.asd.

Parent Component

src (module).

Public Interface

text (function).


4.1.5 esrap-liquid/src/iterators.lisp

Dependency

miscellany.lisp (file).

Source

esrap-liquid.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.6 esrap-liquid/src/rule-storage.lisp

Dependency

iterators.lisp (file).

Source

esrap-liquid.asd.

Parent Component

src (module).

Internals

4.1.7 esrap-liquid/src/memoization.lisp

Dependency

rule-storage.lisp (file).

Source

esrap-liquid.asd.

Parent Component

src (module).

Public Interface

register-context (macro).

Internals

4.1.8 esrap-liquid/src/macro.lisp

Dependency

memoization.lisp (file).

Source

esrap-liquid.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.9 esrap-liquid/src/esrap.lisp

Dependency

macro.lisp (file).

Source

esrap-liquid.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.10 esrap-liquid/src/basic-rules.lisp

Dependency

esrap.lisp (file).

Source

esrap-liquid.asd.

Parent Component

src (module).

Public Interface

any-string (macro).

Internals

4.1.11 esrap-liquid/src/esrap-env.lisp

Dependency

basic-rules.lisp (file).

Source

esrap-liquid.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.12 esrap-liquid/src/iter-extensions.lisp

Dependency

esrap-env.lisp (file).

Source

esrap-liquid.asd.

Parent Component

src (module).

Internals

mk-tokenizer (function).


Previous: , Up: Files   [Contents][Index]

4.2 Static


4.2.1 esrap-liquid/example-sexp.lisp

Dependency

src (module).

Source

esrap-liquid.asd.

Parent Component

esrap-liquid (system).


4.2.2 esrap-liquid/example-symbol-table.lisp

Dependency

example-sexp.lisp (file).

Source

esrap-liquid.asd.

Parent Component

esrap-liquid (system).


4.2.3 esrap-liquid/README

Dependency

example-symbol-table.lisp (file).

Source

esrap-liquid.asd.

Parent Component

esrap-liquid (system).


5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 esrap-liquid

Source

package.lisp.

Use List
  • alexandria.
  • common-lisp.
  • iterate.
Public Interface
Internals

Previous: , Up: Packages   [Contents][Index]

5.2 esrap-liquid-system

Source

esrap-liquid.asd.

Use List
  • asdf/interface.
  • common-lisp.

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Public Interface


6.1.1 Macros

Macro: (&rest clauses)
Package

esrap-liquid.

Source

macro.lisp.

Macro: ! (expr)

Succeeds, whenever parsing of EXPR fails. Does not consume, returns NIL, for compatibility with TEXT

Package

esrap-liquid.

Source

macro.lisp.

Macro: !! (expr)

Succeeds, whenever parsing of EXPR fails. Consumes, assumes than EXPR parses just one character.

Package

esrap-liquid.

Source

macro.lisp.

Macro: & (subexpr)
Package

esrap-liquid.

Source

macro.lisp.

Macro: -> (subexpr)
Package

esrap-liquid.

Source

macro.lisp.

Macro: <- (subexpr)
Package

esrap-liquid.

Source

macro.lisp.

Macro: ? (subexpr)
Package

esrap-liquid.

Source

macro.lisp.

Macro: any-string (length)
Package

esrap-liquid.

Source

basic-rules.lisp.

Macro: character-ranges (&rest char-specs)
Package

esrap-liquid.

Source

esrap.lisp.

Macro: cond-parse (&rest clauses)
Package

esrap-liquid.

Source

macro.lisp.

Macro: define-esrap-env (symbol &key mainly-non-context)
Package

esrap-liquid.

Source

esrap-env.lisp.

Macro: defrule (name args &body body)
Package

esrap-liquid.

Source

macro.lisp.

Macro: descend-with-rule (o!-sym &rest args)
Package

esrap-liquid.

Source

macro.lisp.

Macro: fail-parse (&optional reason)
Package

esrap-liquid.

Source

conditions.lisp.

Macro: fail-parse-format (&optional reason &rest args)
Package

esrap-liquid.

Source

conditions.lisp.

Macro: in-esrap-env (symbol)
Package

esrap-liquid.

Source

esrap-env.lisp.

Macro: list-v (&rest args)

LIST with automatic descent wrapping.

Package

esrap-liquid.

Source

macro.lisp.

Macro: most-full-parse (&rest clauses)
Package

esrap-liquid.

Source

macro.lisp.

Macro: postimes (subexpr)
Package

esrap-liquid.

Source

macro.lisp.

Macro: pred (predicate subexpr)
Package

esrap-liquid.

Source

macro.lisp.

Macro: prog1-v (&rest forms)

PROG1 with automatic descent wrapping.

Package

esrap-liquid.

Source

macro.lisp.

Macro: progm (start meat end)

Prog Middle.

Package

esrap-liquid.

Source

macro.lisp.

Macro: progn-v (&rest forms)

PROGN with automatic descent wrapping.

Package

esrap-liquid.

Source

macro.lisp.

Macro: register-context (context-sym)
Package

esrap-liquid.

Source

memoization.lisp.

Macro: times (subexpr &key from upto exactly)
Package

esrap-liquid.

Source

macro.lisp.


6.1.2 Ordinary functions

Function: maybe-wrap-in-descent (thing)
Package

esrap-liquid.

Source

macro.lisp.

Function: parse (expression text &key start end junk-allowed)

Parses TEXT using EXPRESSION from START to END. Incomplete parses are allowed only if JUNK-ALLOWED is true.

Package

esrap-liquid.

Source

esrap.lisp.

Function: parse-stream (expression stream &key junk-allowed)

Parses STREAM using EXPRESSION. Incomplete parses are allowed if JUNK-ALLOWED is true.

Package

esrap-liquid.

Source

esrap.lisp.

Function: text (&rest arguments)

Arguments must be strings, or lists whose leaves are strings. Catenates all the strings in arguments into a single string.

Package

esrap-liquid.

Source

miscellany.lisp.


6.1.3 Standalone methods

Method: initialize-instance :after ((this buffer-vector) &key &allow-other-keys)
Source

iterators.lisp.

Method: initialize-instance :after ((this cache-iterator) &key &allow-other-keys)
Source

iterators.lisp.

Method: print-object :before ((condition left-recursion) stream)
Source

conditions.lisp.

Method: print-object :around ((condition simple-esrap-error) stream)
Source

conditions.lisp.


6.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.1 Special variables

Special Variable: *cache*
Package

esrap-liquid.

Source

memoization.lisp.

Special Variable: *cap-stash*

Assoc list used to capture temporary variables

Package

esrap-liquid.

Source

macro.lisp.

Special Variable: *debug*
Package

esrap-liquid.

Source

conditions.lisp.

Special Variable: *indentation-hint-table*
Package

esrap-liquid.

Source

esrap.lisp.

Special Variable: *nonterminal-stack*
Package

esrap-liquid.

Source

memoization.lisp.

Special Variable: *rule-context-sensitivity*
Package

esrap-liquid.

Source

rule-storage.lisp.

Special Variable: *rule-stack*
Package

esrap-liquid.

Source

macro.lisp.

Special Variable: *rules*
Package

esrap-liquid.

Source

rule-storage.lisp.

Special Variable: *tracing-indent*
Package

esrap-liquid.

Source

conditions.lisp.

Special Variable: buffer-vector-start-length
Package

esrap-liquid.

Source

iterators.lisp.

Special Variable: contexts
Package

esrap-liquid.

Source

memoization.lisp.

Special Variable: max-failed-position
Package

esrap-liquid.

Source

esrap.lisp.

Special Variable: max-message
Package

esrap-liquid.

Source

esrap.lisp.

Special Variable: max-rule-stack
Package

esrap-liquid.

Source

esrap.lisp.

Special Variable: positive-mood
Package

esrap-liquid.

Source

esrap.lisp.

Special Variable: the-iter
Package

esrap-liquid.

Source

iterators.lisp.

Special Variable: the-length
Package

esrap-liquid.

Source

iterators.lisp.

Special Variable: the-position
Package

esrap-liquid.

Source

iterators.lisp.


6.2.2 Macros

Macro: %defrule (name args &body body)
Package

esrap-liquid.

Source

macro.lisp.

Macro: clause-for-in-iter-1 (&key for in-iter generate)
Package

esrap-liquid.

Source

iterators.lisp.

Macro: def-nocontext-rule (name args &body body)
Package

esrap-liquid.

Source

macro.lisp.

Macro: if-debug (format-str &rest args)
Package

esrap-liquid.

Source

conditions.lisp.

Macro: make-result (result &optional length beginning)
Package

esrap-liquid.

Source

macro.lisp.

Macro: the-position-boundary (&body body)
Package

esrap-liquid.

Source

macro.lisp.

Macro: tracing-init (&body body)
Package

esrap-liquid.

Source

conditions.lisp.

Macro: tracing-level (&body body)
Package

esrap-liquid.

Source

conditions.lisp.

Macro: with-cached-result ((symbol &rest args) &body forms)
Package

esrap-liquid.

Source

memoization.lisp.

Macro: with-fresh-cap-stash (&body body)

Extra level of indirection in *CAP-STASH* is needed to be able to insert new values in it

Package

esrap-liquid.

Source

macro.lisp.

Macro: with-saved-iter-state ((iter) &body body)
Package

esrap-liquid.

Source

iterators.lisp.

Macro: with-sub-cap-stash (&body body)
Package

esrap-liquid.

Source

macro.lisp.

Macro: with-tmp-rule ((var expression) &body body)
Package

esrap-liquid.

Source

esrap.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.3 Ordinary functions

Function: %parse-token-iter (expression token-iter &key junk-allowed)
Package

esrap-liquid.

Source

esrap.lisp.

Function: buffer-error (str &rest args)
Package

esrap-liquid.

Source

iterators.lisp.

Function: calc-new-buffer-length (old-buffer-vector start-pointer)

If we actually only use half of the buffer, shrink it in half.

Package

esrap-liquid.

Source

iterators.lisp.

Function: clear-rules ()
Package

esrap-liquid.

Source

rule-storage.lisp.

Function: context-sensitive-rule-p (symbol)
Package

esrap-liquid.

Source

rule-storage.lisp.

Function: ensure-subpos-hash! (pos-hash pos)
Package

esrap-liquid.

Source

memoization.lisp.

Function: eof-error-p ()
Package

esrap-liquid.

Source

basic-rules.lisp.

Function: eof-p ()
Package

esrap-liquid.

Source

basic-rules.lisp.

Function: failed-parse-p (e)
Package

esrap-liquid.

Source

memoization.lisp.

Function: fast-forward (cache-iterator &optional delta)

Relative fast-forward

Package

esrap-liquid.

Source

iterators.lisp.

Function: (setf get-cached) (symbol position args cache)
Package

esrap-liquid.

Source

memoization.lisp.

Function: hash->assoc (hash)
Package

esrap-liquid.

Source

memoization.lisp.

Function: hint-slime-indentation ()
Package

esrap-liquid.

Source

esrap.lisp.

Function: if-debug-fun (format-str &rest args)
Package

esrap-liquid.

Source

conditions.lisp.

Function: install-common-rules (hash-table)
Package

esrap-liquid.

Source

esrap-env.lisp.

Function: iter-last-text (position)
Package

esrap-liquid.

Source

esrap.lisp.

Function: join (joinee &rest lst)
Package

esrap-liquid.

Source

conditions.lisp.

Function: joinl (joinee lst)
Package

esrap-liquid.

Source

conditions.lisp.

Function: make-cache ()
Package

esrap-liquid.

Source

memoization.lisp.

Function: make-rule-lambda (name args body)
Package

esrap-liquid.

Source

macro.lisp.

Function: mk-cache-iter (sub-iter)
Package

esrap-liquid.

Source

iterators.lisp.

Function: mk-esrap-iter-from-stream (stream)
Package

esrap-liquid.

Source

esrap.lisp.

Function: mk-esrap-iter-from-string (str start end)
Package

esrap-liquid.

Source

esrap.lisp.

Function: mk-stream-iter (stream)
Package

esrap-liquid.

Source

iterators.lisp.

Function: mk-string-iter (string &key start)
Package

esrap-liquid.

Source

iterators.lisp.

Function: mk-tokenizer (expression token-iter &key junk-allowed)
Package

esrap-liquid.

Source

iter-extensions.lisp.

Function: parse-token-iter (expression token-iter &key junk-allowed)
Package

esrap-liquid.

Source

esrap.lisp.

Function: print-buffer-vector (vec)
Package

esrap-liquid.

Source

iterators.lisp.

Function: print-cache-iterator (iter)
Package

esrap-liquid.

Source

iterators.lisp.

Function: print-esrap-cache (cache)
Package

esrap-liquid.

Source

memoization.lisp.

Function: print-iter-state (&optional cached-iter)
Package

esrap-liquid.

Source

iterators.lisp.

Function: propagate-cap-stash-upwards (up-var down-var body)
Package

esrap-liquid.

Source

macro.lisp.

Function: reintern-to-right-package (expression package)
Package

esrap-liquid.

Source

esrap-env.lisp.

Function: rel-rewind (cache-iterator &optional delta)

Relative rewind

Package

esrap-liquid.

Source

iterators.lisp.

Function: rewind (cache-iterator &optional new-pos)
Package

esrap-liquid.

Source

iterators.lisp.

Function: simple-esrap-error (text rule-stack position reason)
Package

esrap-liquid.

Source

conditions.lisp.

Function: wrap-with-esrap-macrolets (body)
Package

esrap-liquid.

Source

macro.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.4 Generic functions

Generic Function: buffer-pop (obj)

Pop the last element of the buffer, but not before the start pointer

Package

esrap-liquid.

Source

iterators.lisp.

Methods
Method: buffer-pop ((obj buffer-vector))
Generic Function: buffer-push (elt obj)

Place object in the end of the buffer, necessarily increasing its size

Package

esrap-liquid.

Source

iterators.lisp.

Methods
Method: buffer-push (elt (obj buffer-vector))
Generic Reader: esrap-error-position (condition)
Package

esrap-liquid.

Methods
Reader Method: esrap-error-position ((condition esrap-error))
Source

conditions.lisp.

Target Slot

position.

Generic Reader: esrap-error-reason (condition)
Package

esrap-liquid.

Methods
Reader Method: esrap-error-reason ((condition esrap-error))
Source

conditions.lisp.

Target Slot

reason.

Generic Reader: esrap-error-text (condition)
Package

esrap-liquid.

Methods
Reader Method: esrap-error-text ((condition esrap-error))
Source

conditions.lisp.

Target Slot

text.

Generic Function: get-cached (symbol position args cache)

Accessor for cached parsing results.

Package

esrap-liquid.

Source

memoization.lisp.

Methods
Method: get-cached (symbol position args (cache esrap-cache))
Generic Function: hard-shrink (obj num-elts-discarded)

Shrink buffer (and cache) the hard way, actually reallocating the buffer and cleaning up cache

Package

esrap-liquid.

Source

iterators.lisp.

Methods
Method: hard-shrink ((obj esrap-cache) num-elts-discarded)
Source

memoization.lisp.

Method: hard-shrink ((obj cache-iterator) num-elts-discarded)
Method: hard-shrink ((obj buffer-vector) (num-elts-discarded integer))
Generic Reader: left-recursion-nonterminal (condition)
Package

esrap-liquid.

Methods
Reader Method: left-recursion-nonterminal ((condition left-recursion))
Source

conditions.lisp.

Target Slot

nonterminal.

Generic Reader: left-recursion-path (condition)
Package

esrap-liquid.

Methods
Reader Method: left-recursion-path ((condition left-recursion))
Source

conditions.lisp.

Target Slot

path.

Generic Function: next-iter (iter)

Main method of iteration protocol

Package

esrap-liquid.

Source

iterators.lisp.

Methods
Method: next-iter ((iter cache-iterator))
Method: next-iter ((iter stream-iter))
Method: next-iter ((iter string-iter))
Generic Reader: rule-stack (condition)
Generic Writer: (setf rule-stack) (condition)
Package

esrap-liquid.

Methods
Reader Method: rule-stack ((condition simple-esrap-error))
Writer Method: (setf rule-stack) ((condition simple-esrap-error))
Source

conditions.lisp.

Target Slot

rule-stack.

Generic Function: soft-shrink (obj num-elts-discarded)

Shrink buffer (and cache) the soft way, just moving the start pointer

Package

esrap-liquid.

Source

iterators.lisp.

Methods
Method: soft-shrink ((obj esrap-cache) num-elts-discarded)
Source

memoization.lisp.

Method: soft-shrink ((obj buffer-vector) (num-elts-discarded integer))
Generic Function: start-of-iter-p (iter)

T if the given iter is at the start. True by default.

Package

esrap-liquid.

Source

iterators.lisp.

Methods
Method: start-of-iter-p ((iter cache-iterator))
Method: start-of-iter-p (iter)

Next: , Previous: , Up: Internals   [Contents][Index]

6.2.5 Conditions

Condition: buffer-error
Package

esrap-liquid.

Source

iterators.lisp.

Direct superclasses

error.

Direct slots
Slot: msg
Initform

(quote nil)

Initargs

:msg

Condition: esrap-error

Signaled when an Esrap parse fails. Use ESRAP-ERROR-TEXT to obtain the string that was being parsed, and ESRAP-ERROR-POSITION the position at which the error occurred.

Package

esrap-liquid.

Source

conditions.lisp.

Direct superclasses

parse-error.

Direct subclasses
Direct methods
Direct slots
Slot: text
Initform

(quote nil)

Initargs

:text

Readers

esrap-error-text.

Writers

This slot is read-only.

Slot: position
Package

common-lisp.

Initform

(quote nil)

Initargs

:position

Readers

esrap-error-position.

Writers

This slot is read-only.

Slot: reason
Initform

(quote nil)

Initargs

:reason

Readers

esrap-error-reason.

Writers

This slot is read-only.

Condition: internal-esrap-error
Package

esrap-liquid.

Source

conditions.lisp.

Direct superclasses

esrap-error.

Condition: left-recursion

Signaled when left recursion is detected during Esrap parsing. LEFT-RECURSION-NONTERMINAL names the symbol for which left recursion was detected, and LEFT-RECURSION-PATH lists nonterminals of which the left recursion cycle consists.

Package

esrap-liquid.

Source

conditions.lisp.

Direct superclasses

esrap-error.

Direct methods
Direct slots
Slot: nonterminal
Initform

(quote nil)

Initargs

:nonterminal

Readers

left-recursion-nonterminal.

Writers

This slot is read-only.

Slot: path
Initform

(quote nil)

Initargs

:path

Readers

left-recursion-path.

Writers

This slot is read-only.

Condition: simple-esrap-error
Package

esrap-liquid.

Source

conditions.lisp.

Direct superclasses
Direct methods
Direct slots
Slot: rule-stack
Initargs

:rule-stack

Readers

rule-stack.

Writers

(setf rule-stack).

Condition: stop-iteration
Package

esrap-liquid.

Source

iterators.lisp.

Direct superclasses

error.


Previous: , Up: Internals   [Contents][Index]

6.2.6 Classes

Class: buffer-vector
Package

esrap-liquid.

Source

iterators.lisp.

Direct methods
Direct slots
Slot: vector
Package

common-lisp.

Slot: start-pointer
Initform

0

Class: cache-iterator
Package

esrap-liquid.

Source

iterators.lisp.

Direct methods
Direct slots
Slot: cached-vals
Slot: cached-pos
Initform

0

Slot: sub-iter
Initform

(error "please, specify underlying iterator")

Initargs

:sub-iter

Class: esrap-cache
Package

esrap-liquid.

Source

memoization.lisp.

Direct methods
Direct slots
Slot: pos-hashtable
Initform

(make-hash-table :test (function equal))

Slot: start-pos
Initform

0

Class: stream-iter
Package

esrap-liquid.

Source

iterators.lisp.

Direct methods

next-iter.

Direct slots
Slot: stream
Package

common-lisp.

Initform

(error "steam is required argument")

Initargs

:stream

Class: string-iter
Package

esrap-liquid.

Source

iterators.lisp.

Direct methods

next-iter.

Direct slots
Slot: pos
Initform

0

Initargs

:start

Slot: str
Initform

""

Initargs

:string


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   !   %   &   (   -   <   ?    
A   B   C   D   E   F   G   H   I   J   L   M   N   P   R   S   T   W  
Index Entry  Section

!
!: Public macros
!!: Public macros

%
%defrule: Private macros
%parse-token-iter: Private ordinary functions

&
&: Public macros

(
(setf get-cached): Private ordinary functions
(setf rule-stack): Private generic functions
(setf rule-stack): Private generic functions

-
->: Public macros

<
<-: Public macros

?
?: Public macros

: Public macros

A
any-string: Public macros

B
buffer-error: Private ordinary functions
buffer-pop: Private generic functions
buffer-pop: Private generic functions
buffer-push: Private generic functions
buffer-push: Private generic functions

C
calc-new-buffer-length: Private ordinary functions
character-ranges: Public macros
clause-for-in-iter-1: Private macros
clear-rules: Private ordinary functions
cond-parse: Public macros
context-sensitive-rule-p: Private ordinary functions

D
def-nocontext-rule: Private macros
define-esrap-env: Public macros
defrule: Public macros
descend-with-rule: Public macros

E
ensure-subpos-hash!: Private ordinary functions
eof-error-p: Private ordinary functions
eof-p: Private ordinary functions
esrap-error-position: Private generic functions
esrap-error-position: Private generic functions
esrap-error-reason: Private generic functions
esrap-error-reason: Private generic functions
esrap-error-text: Private generic functions
esrap-error-text: Private generic functions

F
fail-parse: Public macros
fail-parse-format: Public macros
failed-parse-p: Private ordinary functions
fast-forward: Private ordinary functions
Function, %parse-token-iter: Private ordinary functions
Function, (setf get-cached): Private ordinary functions
Function, buffer-error: Private ordinary functions
Function, calc-new-buffer-length: Private ordinary functions
Function, clear-rules: Private ordinary functions
Function, context-sensitive-rule-p: Private ordinary functions
Function, ensure-subpos-hash!: Private ordinary functions
Function, eof-error-p: Private ordinary functions
Function, eof-p: Private ordinary functions
Function, failed-parse-p: Private ordinary functions
Function, fast-forward: Private ordinary functions
Function, hash->assoc: Private ordinary functions
Function, hint-slime-indentation: Private ordinary functions
Function, if-debug-fun: Private ordinary functions
Function, install-common-rules: Private ordinary functions
Function, iter-last-text: Private ordinary functions
Function, join: Private ordinary functions
Function, joinl: Private ordinary functions
Function, make-cache: Private ordinary functions
Function, make-rule-lambda: Private ordinary functions
Function, maybe-wrap-in-descent: Public ordinary functions
Function, mk-cache-iter: Private ordinary functions
Function, mk-esrap-iter-from-stream: Private ordinary functions
Function, mk-esrap-iter-from-string: Private ordinary functions
Function, mk-stream-iter: Private ordinary functions
Function, mk-string-iter: Private ordinary functions
Function, mk-tokenizer: Private ordinary functions
Function, parse: Public ordinary functions
Function, parse-stream: Public ordinary functions
Function, parse-token-iter: Private ordinary functions
Function, print-buffer-vector: Private ordinary functions
Function, print-cache-iterator: Private ordinary functions
Function, print-esrap-cache: Private ordinary functions
Function, print-iter-state: Private ordinary functions
Function, propagate-cap-stash-upwards: Private ordinary functions
Function, reintern-to-right-package: Private ordinary functions
Function, rel-rewind: Private ordinary functions
Function, rewind: Private ordinary functions
Function, simple-esrap-error: Private ordinary functions
Function, text: Public ordinary functions
Function, wrap-with-esrap-macrolets: Private ordinary functions

G
Generic Function, (setf rule-stack): Private generic functions
Generic Function, buffer-pop: Private generic functions
Generic Function, buffer-push: Private generic functions
Generic Function, esrap-error-position: Private generic functions
Generic Function, esrap-error-reason: Private generic functions
Generic Function, esrap-error-text: Private generic functions
Generic Function, get-cached: Private generic functions
Generic Function, hard-shrink: Private generic functions
Generic Function, left-recursion-nonterminal: Private generic functions
Generic Function, left-recursion-path: Private generic functions
Generic Function, next-iter: Private generic functions
Generic Function, rule-stack: Private generic functions
Generic Function, soft-shrink: Private generic functions
Generic Function, start-of-iter-p: Private generic functions
get-cached: Private generic functions
get-cached: Private generic functions

H
hard-shrink: Private generic functions
hard-shrink: Private generic functions
hard-shrink: Private generic functions
hard-shrink: Private generic functions
hash->assoc: Private ordinary functions
hint-slime-indentation: Private ordinary functions

I
if-debug: Private macros
if-debug-fun: Private ordinary functions
in-esrap-env: Public macros
initialize-instance: Public standalone methods
initialize-instance: Public standalone methods
install-common-rules: Private ordinary functions
iter-last-text: Private ordinary functions

J
join: Private ordinary functions
joinl: Private ordinary functions

L
left-recursion-nonterminal: Private generic functions
left-recursion-nonterminal: Private generic functions
left-recursion-path: Private generic functions
left-recursion-path: Private generic functions
list-v: Public macros

M
Macro, !: Public macros
Macro, !!: Public macros
Macro, %defrule: Private macros
Macro, &: Public macros
Macro, ->: Public macros
Macro, <-: Public macros
Macro, ?: Public macros
Macro, any-string: Public macros
Macro, character-ranges: Public macros
Macro, clause-for-in-iter-1: Private macros
Macro, cond-parse: Public macros
Macro, def-nocontext-rule: Private macros
Macro, define-esrap-env: Public macros
Macro, defrule: Public macros
Macro, descend-with-rule: Public macros
Macro, fail-parse: Public macros
Macro, fail-parse-format: Public macros
Macro, if-debug: Private macros
Macro, in-esrap-env: Public macros
Macro, list-v: Public macros
Macro, make-result: Private macros
Macro, most-full-parse: Public macros
Macro, postimes: Public macros
Macro, pred: Public macros
Macro, prog1-v: Public macros
Macro, progm: Public macros
Macro, progn-v: Public macros
Macro, register-context: Public macros
Macro, the-position-boundary: Private macros
Macro, times: Public macros
Macro, tracing-init: Private macros
Macro, tracing-level: Private macros
Macro, with-cached-result: Private macros
Macro, with-fresh-cap-stash: Private macros
Macro, with-saved-iter-state: Private macros
Macro, with-sub-cap-stash: Private macros
Macro, with-tmp-rule: Private macros
Macro, : Public macros
make-cache: Private ordinary functions
make-result: Private macros
make-rule-lambda: Private ordinary functions
maybe-wrap-in-descent: Public ordinary functions
Method, (setf rule-stack): Private generic functions
Method, buffer-pop: Private generic functions
Method, buffer-push: Private generic functions
Method, esrap-error-position: Private generic functions
Method, esrap-error-reason: Private generic functions
Method, esrap-error-text: Private generic functions
Method, get-cached: Private generic functions
Method, hard-shrink: Private generic functions
Method, hard-shrink: Private generic functions
Method, hard-shrink: Private generic functions
Method, initialize-instance: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, left-recursion-nonterminal: Private generic functions
Method, left-recursion-path: Private generic functions
Method, next-iter: Private generic functions
Method, next-iter: Private generic functions
Method, next-iter: Private generic functions
Method, print-object: Public standalone methods
Method, print-object: Public standalone methods
Method, rule-stack: Private generic functions
Method, soft-shrink: Private generic functions
Method, soft-shrink: Private generic functions
Method, start-of-iter-p: Private generic functions
Method, start-of-iter-p: Private generic functions
mk-cache-iter: Private ordinary functions
mk-esrap-iter-from-stream: Private ordinary functions
mk-esrap-iter-from-string: Private ordinary functions
mk-stream-iter: Private ordinary functions
mk-string-iter: Private ordinary functions
mk-tokenizer: Private ordinary functions
most-full-parse: Public macros

N
next-iter: Private generic functions
next-iter: Private generic functions
next-iter: Private generic functions
next-iter: Private generic functions

P
parse: Public ordinary functions
parse-stream: Public ordinary functions
parse-token-iter: Private ordinary functions
postimes: Public macros
pred: Public macros
print-buffer-vector: Private ordinary functions
print-cache-iterator: Private ordinary functions
print-esrap-cache: Private ordinary functions
print-iter-state: Private ordinary functions
print-object: Public standalone methods
print-object: Public standalone methods
prog1-v: Public macros
progm: Public macros
progn-v: Public macros
propagate-cap-stash-upwards: Private ordinary functions

R
register-context: Public macros
reintern-to-right-package: Private ordinary functions
rel-rewind: Private ordinary functions
rewind: Private ordinary functions
rule-stack: Private generic functions
rule-stack: Private generic functions

S
simple-esrap-error: Private ordinary functions
soft-shrink: Private generic functions
soft-shrink: Private generic functions
soft-shrink: Private generic functions
start-of-iter-p: Private generic functions
start-of-iter-p: Private generic functions
start-of-iter-p: Private generic functions

T
text: Public ordinary functions
the-position-boundary: Private macros
times: Public macros
tracing-init: Private macros
tracing-level: Private macros

W
with-cached-result: Private macros
with-fresh-cap-stash: Private macros
with-saved-iter-state: Private macros
with-sub-cap-stash: Private macros
with-tmp-rule: Private macros
wrap-with-esrap-macrolets: Private ordinary functions

Jump to:   !   %   &   (   -   <   ?    
A   B   C   D   E   F   G   H   I   J   L   M   N   P   R   S   T   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
B   C   M   N   P   R   S   T   V  
Index Entry  Section

*
*cache*: Private special variables
*cap-stash*: Private special variables
*debug*: Private special variables
*indentation-hint-table*: Private special variables
*nonterminal-stack*: Private special variables
*rule-context-sensitivity*: Private special variables
*rule-stack*: Private special variables
*rules*: Private special variables
*tracing-indent*: Private special variables

B
buffer-vector-start-length: Private special variables

C
cached-pos: Private classes
cached-vals: Private classes
contexts: Private special variables

M
max-failed-position: Private special variables
max-message: Private special variables
max-rule-stack: Private special variables
msg: Private conditions

N
nonterminal: Private conditions

P
path: Private conditions
pos: Private classes
pos-hashtable: Private classes
position: Private conditions
positive-mood: Private special variables

R
reason: Private conditions
rule-stack: Private conditions

S
Slot, cached-pos: Private classes
Slot, cached-vals: Private classes
Slot, msg: Private conditions
Slot, nonterminal: Private conditions
Slot, path: Private conditions
Slot, pos: Private classes
Slot, pos-hashtable: Private classes
Slot, position: Private conditions
Slot, reason: Private conditions
Slot, rule-stack: Private conditions
Slot, start-pointer: Private classes
Slot, start-pos: Private classes
Slot, str: Private classes
Slot, stream: Private classes
Slot, sub-iter: Private classes
Slot, text: Private conditions
Slot, vector: Private classes
Special Variable, *cache*: Private special variables
Special Variable, *cap-stash*: Private special variables
Special Variable, *debug*: Private special variables
Special Variable, *indentation-hint-table*: Private special variables
Special Variable, *nonterminal-stack*: Private special variables
Special Variable, *rule-context-sensitivity*: Private special variables
Special Variable, *rule-stack*: Private special variables
Special Variable, *rules*: Private special variables
Special Variable, *tracing-indent*: Private special variables
Special Variable, buffer-vector-start-length: Private special variables
Special Variable, contexts: Private special variables
Special Variable, max-failed-position: Private special variables
Special Variable, max-message: Private special variables
Special Variable, max-rule-stack: Private special variables
Special Variable, positive-mood: Private special variables
Special Variable, the-iter: Private special variables
Special Variable, the-length: Private special variables
Special Variable, the-position: Private special variables
start-pointer: Private classes
start-pos: Private classes
str: Private classes
stream: Private classes
sub-iter: Private classes

T
text: Private conditions
the-iter: Private special variables
the-length: Private special variables
the-position: Private special variables

V
vector: Private classes

Jump to:   *  
B   C   M   N   P   R   S   T   V  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   B   C   E   F   I   L   M   P   R   S  
Index Entry  Section

B
basic-rules.lisp: The esrap-liquid/src/basic-rules․lisp file
buffer-error: Private conditions
buffer-vector: Private classes

C
cache-iterator: Private classes
Class, buffer-vector: Private classes
Class, cache-iterator: Private classes
Class, esrap-cache: Private classes
Class, stream-iter: Private classes
Class, string-iter: Private classes
Condition, buffer-error: Private conditions
Condition, esrap-error: Private conditions
Condition, internal-esrap-error: Private conditions
Condition, left-recursion: Private conditions
Condition, simple-esrap-error: Private conditions
Condition, stop-iteration: Private conditions
conditions.lisp: The esrap-liquid/src/conditions․lisp file

E
esrap-cache: Private classes
esrap-env.lisp: The esrap-liquid/src/esrap-env․lisp file
esrap-error: Private conditions
esrap-liquid: The esrap-liquid system
esrap-liquid: The esrap-liquid package
esrap-liquid-system: The esrap-liquid-system package
esrap-liquid.asd: The esrap-liquid/esrap-liquid․asd file
esrap.lisp: The esrap-liquid/src/esrap․lisp file
example-sexp.lisp: The esrap-liquid/example-sexp․lisp file
example-symbol-table.lisp: The esrap-liquid/example-symbol-table․lisp file

F
File, basic-rules.lisp: The esrap-liquid/src/basic-rules․lisp file
File, conditions.lisp: The esrap-liquid/src/conditions․lisp file
File, esrap-env.lisp: The esrap-liquid/src/esrap-env․lisp file
File, esrap-liquid.asd: The esrap-liquid/esrap-liquid․asd file
File, esrap.lisp: The esrap-liquid/src/esrap․lisp file
File, example-sexp.lisp: The esrap-liquid/example-sexp․lisp file
File, example-symbol-table.lisp: The esrap-liquid/example-symbol-table․lisp file
File, iter-extensions.lisp: The esrap-liquid/src/iter-extensions․lisp file
File, iterators.lisp: The esrap-liquid/src/iterators․lisp file
File, macro.lisp: The esrap-liquid/src/macro․lisp file
File, memoization.lisp: The esrap-liquid/src/memoization․lisp file
File, miscellany.lisp: The esrap-liquid/src/miscellany․lisp file
File, package.lisp: The esrap-liquid/src/package․lisp file
File, readme: The esrap-liquid/readme file
File, rule-storage.lisp: The esrap-liquid/src/rule-storage․lisp file

I
internal-esrap-error: Private conditions
iter-extensions.lisp: The esrap-liquid/src/iter-extensions․lisp file
iterators.lisp: The esrap-liquid/src/iterators․lisp file

L
left-recursion: Private conditions

M
macro.lisp: The esrap-liquid/src/macro․lisp file
memoization.lisp: The esrap-liquid/src/memoization․lisp file
miscellany.lisp: The esrap-liquid/src/miscellany․lisp file
Module, src: The esrap-liquid/src module

P
Package, esrap-liquid: The esrap-liquid package
Package, esrap-liquid-system: The esrap-liquid-system package
package.lisp: The esrap-liquid/src/package․lisp file

R
readme: The esrap-liquid/readme file
rule-storage.lisp: The esrap-liquid/src/rule-storage․lisp file

S
simple-esrap-error: Private conditions
src: The esrap-liquid/src module
stop-iteration: Private conditions
stream-iter: Private classes
string-iter: Private classes
System, esrap-liquid: The esrap-liquid system

Jump to:   B   C   E   F   I   L   M   P   R   S