Prepare for removing base environment: special support for any
This commit is contained in:
parent
1c07573178
commit
0970898065
|
@ -9,6 +9,7 @@ export const $SignedInteger = Symbol.for("SignedInteger");
|
||||||
export const $String = Symbol.for("String");
|
export const $String = Symbol.for("String");
|
||||||
export const $Symbol = Symbol.for("Symbol");
|
export const $Symbol = Symbol.for("Symbol");
|
||||||
export const $and = Symbol.for("and");
|
export const $and = Symbol.for("and");
|
||||||
|
export const $any = Symbol.for('any');
|
||||||
export const $atom = Symbol.for("atom");
|
export const $atom = Symbol.for("atom");
|
||||||
export const $definitions = Symbol.for("definitions");
|
export const $definitions = Symbol.for("definitions");
|
||||||
export const $dict = Symbol.for("dict");
|
export const $dict = Symbol.for("dict");
|
||||||
|
@ -75,6 +76,7 @@ export type Alternative = (_.Record<(typeof $and), [Array<NamedPattern>], _ptr>
|
||||||
export type Pattern = (SimplePattern | CompoundPattern);
|
export type Pattern = (SimplePattern | CompoundPattern);
|
||||||
|
|
||||||
export type SimplePattern = (
|
export type SimplePattern = (
|
||||||
|
_.Record<(typeof $any), [], _ptr> |
|
||||||
_.Record<(typeof $atom), [AtomKind], _ptr> |
|
_.Record<(typeof $atom), [AtomKind], _ptr> |
|
||||||
_.Record<(typeof $pointer), [], _ptr> |
|
_.Record<(typeof $pointer), [], _ptr> |
|
||||||
_.Record<(typeof $lit), [_val], _ptr> |
|
_.Record<(typeof $lit), [_val], _ptr> |
|
||||||
|
@ -397,6 +399,7 @@ export function decodePattern(d: _.TypedDecoder<_ptr>): Pattern | undefined {
|
||||||
export function isSimplePattern(v: any): v is SimplePattern {
|
export function isSimplePattern(v: any): v is SimplePattern {
|
||||||
return _.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && (
|
return _.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && (
|
||||||
(
|
(
|
||||||
|
(_.is(v.label, $any) && ((v.length === 0))) ||
|
||||||
(_.is(v.label, $atom) && ((v.length === 1) && isAtomKind(v[0]))) ||
|
(_.is(v.label, $atom) && ((v.length === 1) && isAtomKind(v[0]))) ||
|
||||||
(_.is(v.label, $pointer) && ((v.length === 0))) ||
|
(_.is(v.label, $pointer) && ((v.length === 0))) ||
|
||||||
(_.is(v.label, $lit) && ((v.length === 1) && true)) ||
|
(_.is(v.label, $lit) && ((v.length === 1) && true)) ||
|
||||||
|
@ -417,6 +420,12 @@ export function decodeSimplePattern(d: _.TypedDecoder<_ptr>): SimplePattern | un
|
||||||
let _tmp0, _tmp1: any;
|
let _tmp0, _tmp1: any;
|
||||||
_tmp0 = d.next();
|
_tmp0 = d.next();
|
||||||
_tmp1 = d.mark();
|
_tmp1 = d.mark();
|
||||||
|
{
|
||||||
|
if (_.is(_tmp0, $any)) {
|
||||||
|
if (d.closeCompound()) return _.Record<(typeof $any), []>($any, []);
|
||||||
|
d.restoreMark(_tmp1);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (_.is(_tmp0, $atom)) {
|
if (_.is(_tmp0, $atom)) {
|
||||||
let _tmp2, _tmp3: any;
|
let _tmp2, _tmp3: any;
|
||||||
_tmp3 = decodeAtomKind(d);
|
_tmp3 = decodeAtomKind(d);
|
||||||
|
|
|
@ -28,10 +28,13 @@ Alternative = <and [@patterns NamedPattern ...]> / Pattern .
|
||||||
Pattern = SimplePattern / CompoundPattern .
|
Pattern = SimplePattern / CompoundPattern .
|
||||||
|
|
||||||
SimplePattern =
|
SimplePattern =
|
||||||
; special builtins
|
; any
|
||||||
|
/ =any
|
||||||
|
|
||||||
|
; special builtins: bool, float, double, int, string, bytes, symbol
|
||||||
/ <atom @atomKind AtomKind>
|
/ <atom @atomKind AtomKind>
|
||||||
|
|
||||||
; matches a pointer in the input
|
; matches a pointer in the input: ref
|
||||||
/ <pointer>
|
/ <pointer>
|
||||||
|
|
||||||
; =symbol, <<lit> any>, or plain non-symbol atom
|
; =symbol, <<lit> any>, or plain non-symbol atom
|
||||||
|
|
Loading…
Reference in New Issue