Documentation ¶
Overview ¶
Package rules defines a syntax for rule-based re-writing DSLs. The supported syntax is as follows:
comment = < go comment syntax > string = < go double-quote syntax > | < go backtick syntax > identifier = < go identifier > rule = value {',' value} '->' term term = (identifier ':' value) | identifier | value value = list | string list = '(' item {space+ item} ')'
For example:
// here is a line comment (foo "quoted-string" x:(baz `backtick-string`)) -> x
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Rule ¶
type Rule struct { // From is the conjunction of // expressions to match against. From []Value // To is the value associated with // the right-hand-side of the rule. To Term // Location is the original textual position // at which the rule began Location scanner.Position }
Rule represents one rule. The rule package does not assign any semantic meaning to the structure of a Rule; it only defines the syntax for Rules.
type Term ¶
type Term struct { // Name is the name (identifier) of this term. // If Value is non-nil, then Name // may be the empty string. Name string // Value is the value of the term. // Value may be nil if this term // is a bare identifier. Value Value // Input is scratch space that can // be used by external packages. Input string // Location is the location of the term // in the original text file. It can be // used to provide more helpful error messages. Location scanner.Position }
Term is a term in a rule. Every term in a rule is optionally named (see Name) so that it can be referred to in other terms.
Click to show internal directories.
Click to hide internal directories.