| java.lang.Object kawa.lang.Pattern kawa.lang.SyntaxPattern
SyntaxPattern | public class SyntaxPattern extends Pattern implements Externalizable(Code) | | This encodes a pattern from a Scheem syntax-case or syntax-rules.
|
Field Summary | |
final static int | MATCH_ANY The instruction 8*i+MATCH_ANY matches any form,
It sets vars[i] to the matched form. | final static int | MATCH_ANY_CAR The instruction 8*i+MATCH_CAR matches the car of a Pair,
It sets vars[i] to the Pair itself. | final static int | MATCH_EQUALS The instruction 8*i+MATCH_EQUALS matches the literal values literals[i]. | final static int | MATCH_IGNORE Match anything and ignoe it. | final static int | MATCH_LENGTH The instruction 8*i+MATCH_LENGTH matches a pure list
of length 2*i or an impure list of 2*i+1 pairs.
It is followed by a pattern which must also match. | final static int | MATCH_LREPEAT The instruction 8*i+MATCH_LREPEAT matches a repeated
pattern. | final static int | MATCH_MISC This 3-bit "opcode" is used for shorter operand-less instructions. | final static int | MATCH_NIL Matches List.Empty . | final static int | MATCH_PAIR The instruction 8*i+MATCH_PAIR matches a Pair.
Its car must match the pattern at pc+1 , while
its cdr must match the mattern at pc+1+i . | final static int | MATCH_VECTOR Matches a vector (FVector).
Matches a vecetor v if the following list pattern (at pc+1)
matches (vector->list v). | final static int | MATCH_WIDE The instruction 8*i+MATCH_WIDE is a prefix.
It causes i<<13 to be added to the parameter
(i ) of the following instruction. | Object[] | literals | String | program An encoding of the pattern in a compact form.
This is a sequence of "matching instructions". | int | varCount |
Method Summary | |
public static Object[] | allocVars(int varCount, Object[] outer) The compiler calls this method to implement syntax-case. | public void | disassemble() | public void | disassemble(java.io.PrintWriter ps, Translator tr) | void | disassemble(java.io.PrintWriter ps, Translator tr, int start, int limit) | public static Object[] | getLiteralsList(Object list, SyntaxForm syntax, Translator tr) Parse the literals list in a syntax-rules or syntax-case. | public static boolean | literalIdentifierEq(Object id1, ScopeExp sc1, Object literal2) | public static boolean | literalIdentifierEq(Object id1, ScopeExp sc1, Object id2, ScopeExp sc2) | public boolean | match(Object obj, Object[] vars, int start_vars) | public boolean | match(Object obj, Object[] vars, int start_vars, int pc, SyntaxForm syntax) | boolean | match_car(Pair p, Object[] vars, int start_vars, int pc, SyntaxForm syntax) Match the car of a Pair .
This special case (instead of of just matching the car
directly), is so we can copy PairWithPosition line number
info into the output of a template. | public void | print(Consumer out) | public void | readExternal(ObjectInput in) | void | translate(Object pattern, StringBuffer program, Object[] literal_identifiers, int nesting, Vector literals, SyntaxForm syntax, char context, Translator tr) | public int | varCount() | public void | writeExternal(ObjectOutput out) |
MATCH_ANY | final static int MATCH_ANY(Code) | | The instruction 8*i+MATCH_ANY matches any form,
It sets vars[i] to the matched form.
|
MATCH_ANY_CAR | final static int MATCH_ANY_CAR(Code) | | The instruction 8*i+MATCH_CAR matches the car of a Pair,
It sets vars[i] to the Pair itself.
|
MATCH_EQUALS | final static int MATCH_EQUALS(Code) | | The instruction 8*i+MATCH_EQUALS matches the literal values literals[i].
|
MATCH_IGNORE | final static int MATCH_IGNORE(Code) | | Match anything and ignoe it.
|
MATCH_LENGTH | final static int MATCH_LENGTH(Code) | | The instruction 8*i+MATCH_LENGTH matches a pure list
of length 2*i or an impure list of 2*i+1 pairs.
It is followed by a pattern which must also match.
|
MATCH_LREPEAT | final static int MATCH_LREPEAT(Code) | | The instruction 8*i+MATCH_LREPEAT matches a repeated
pattern. The repeated sub-pattern starts at pc+1 ,
and is i chars long. Following that (at pc+1+i )
is the index of the first pattern variable in the sub-pattern,
followed by the count of pattern variables in the sub-pattern.
(Both are shifted left by 3 in case we need MATCH_WIDE ).
This is followed either by a MATCH_NIL (in which case
all remaining elements must match the repeated sub-pattern),
or by a MATCH_LENGTH (which must match the tail).
|
MATCH_MISC | final static int MATCH_MISC(Code) | | This 3-bit "opcode" is used for shorter operand-less instructions.
|
MATCH_NIL | final static int MATCH_NIL(Code) | | Matches List.Empty .
|
MATCH_PAIR | final static int MATCH_PAIR(Code) | | The instruction 8*i+MATCH_PAIR matches a Pair.
Its car must match the pattern at pc+1 , while
its cdr must match the mattern at pc+1+i .
|
MATCH_VECTOR | final static int MATCH_VECTOR(Code) | | Matches a vector (FVector).
Matches a vecetor v if the following list pattern (at pc+1)
matches (vector->list v).
|
MATCH_WIDE | final static int MATCH_WIDE(Code) | | The instruction 8*i+MATCH_WIDE is a prefix.
It causes i<<13 to be added to the parameter
(i ) of the following instruction.
|
program | String program(Code) | | An encoding of the pattern in a compact form.
This is a sequence of "matching instructions". These have a 3-bit
"opcode", which is one of the MATCH_XXX cosntants.
The leaves 13 bits available as an operand; if that isn't enough the
MATCH_WIDE "instruction" can be used to modify the
following instruction.
|
allocVars | public static Object[] allocVars(int varCount, Object[] outer)(Code) | | The compiler calls this method to implement syntax-case.
|
disassemble | public void disassemble()(Code) | | |
match_car | boolean match_car(Pair p, Object[] vars, int start_vars, int pc, SyntaxForm syntax)(Code) | | Match the car of a Pair .
This special case (instead of of just matching the car
directly), is so we can copy PairWithPosition line number
info into the output of a template.
|
varCount | public int varCount()(Code) | | |
|
|