@danielx/civet 0.3.4 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -135,6 +135,10 @@ Things Added that CoffeeScript didn't
135
135
  ---
136
136
 
137
137
  - TypeScript Types
138
+ - Function annotaions
139
+ - `namespace`
140
+ - `interface`
141
+ - TypeParameters
138
142
  - JS Compatability
139
143
  - `var`, `let`, `const`
140
144
  - JS Comment Syntax `//` and `/* */`
@@ -147,7 +151,7 @@ Things Added that CoffeeScript didn't
147
151
  - Convenience for ES6+ Features
148
152
  - `<` as `extends` shorthand
149
153
  - `@#id` -> `this.#id` shorthand for private identifiers
150
- - `import` shorthand `x from "./x"` -> `import x from "./x"`
154
+ - `import` shorthand `x from ./x` -> `import x from "./x"`
151
155
  - ClassStaticBlock
152
156
  - `get`/`set` method definitions
153
157
  - Private identifiers `#id`
package/dist/browser.js CHANGED
@@ -498,6 +498,8 @@ var Civet = (() => {
498
498
  PropertyDefinition,
499
499
  PropertyName,
500
500
  MethodDefinition,
501
+ MethodModifier,
502
+ MethodSignature,
501
503
  ClassElementName,
502
504
  PrivateIdentifier,
503
505
  GeneratorMethod,
@@ -624,11 +626,19 @@ var Civet = (() => {
624
626
  JSXText,
625
627
  JSXChildExpression,
626
628
  TypeDeclaration,
629
+ TypeDeclarationModifier,
630
+ TypeDeclarationRest,
631
+ TypeKeyword,
632
+ Interface,
633
+ Namespace,
627
634
  InterfaceBlock,
628
635
  NestedInterfaceProperties,
629
636
  NestedInterfaceProperty,
630
637
  InterfaceProperty,
631
638
  InterfacePropertyDelimiter,
639
+ NamespaceBlock,
640
+ NestedTypeDeclarations,
641
+ NestedTypeDeclaration,
632
642
  TypeIndexSignature,
633
643
  TypeIndex,
634
644
  TypeSuffix,
@@ -800,13 +810,17 @@ var Civet = (() => {
800
810
  var $L125 = $L("</");
801
811
  var $L126 = $L("<>");
802
812
  var $L127 = $L("</>");
803
- var $L128 = $L("readonly");
804
- var $L129 = $L("asserts");
805
- var $L130 = $L("keyof");
806
- var $L131 = $L("infer");
807
- var $L132 = $L("[]");
808
- var $L133 = $L(" ");
809
- var $L134 = $L(" ");
813
+ var $L128 = $L("declare");
814
+ var $L129 = $L("type");
815
+ var $L130 = $L("interface");
816
+ var $L131 = $L("namespace");
817
+ var $L132 = $L("readonly");
818
+ var $L133 = $L("asserts");
819
+ var $L134 = $L("keyof");
820
+ var $L135 = $L("infer");
821
+ var $L136 = $L("[]");
822
+ var $L137 = $L(" ");
823
+ var $L138 = $L(" ");
810
824
  var $R0 = $R(new RegExp("(of)(?!\\p{ID_Continue})", "suy"));
811
825
  var $R1 = $R(new RegExp("(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$])*", "suy"));
812
826
  var $R2 = $R(new RegExp("[!~+-]", "suy"));
@@ -837,14 +851,12 @@ var Civet = (() => {
837
851
  var $R27 = $R(new RegExp('"[^"]*"', "suy"));
838
852
  var $R28 = $R(new RegExp("'[^']*'", "suy"));
839
853
  var $R29 = $R(new RegExp("[^{}<>]+", "suy"));
840
- var $R30 = $R(new RegExp("type(?!\\p{ID_Continue})", "suy"));
841
- var $R31 = $R(new RegExp("interface(?!\\p{ID_Continue})", "suy"));
842
- var $R32 = $R(new RegExp("[+-]?", "suy"));
843
- var $R33 = $R(new RegExp("[+-]", "suy"));
844
- var $R34 = $R(new RegExp("#![^\\r\\n]*", "suy"));
845
- var $R35 = $R(new RegExp("[\\t ]*", "suy"));
846
- var $R36 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
847
- var $R37 = $R(new RegExp("$", "suy"));
854
+ var $R30 = $R(new RegExp("[+-]?", "suy"));
855
+ var $R31 = $R(new RegExp("[+-]", "suy"));
856
+ var $R32 = $R(new RegExp("#![^\\r\\n]*", "suy"));
857
+ var $R33 = $R(new RegExp("[\\t ]*", "suy"));
858
+ var $R34 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
859
+ var $R35 = $R(new RegExp("$", "suy"));
848
860
  var Program$0 = $S(Init, __, $Q(TopLevelStatement), __);
849
861
  function Program(state) {
850
862
  if (state.verbose)
@@ -1397,7 +1409,7 @@ var Civet = (() => {
1397
1409
  return MetaProperty$0(state) || MetaProperty$1(state);
1398
1410
  }
1399
1411
  }
1400
- var Parameters$0 = $S($EXPECT($L1, fail, 'Parameters "("'), $Q(ParameterElement), __, $EXPECT($L2, fail, 'Parameters ")"'));
1412
+ var Parameters$0 = $S($E(TypeParameters), $EXPECT($L1, fail, 'Parameters "("'), $Q(ParameterElement), __, $EXPECT($L2, fail, 'Parameters ")"'));
1401
1413
  var Parameters$1 = $T($EXPECT($L32, fail, 'Parameters ""'), function(value) {
1402
1414
  return "()";
1403
1415
  });
@@ -1898,6 +1910,26 @@ var Civet = (() => {
1898
1910
  return MethodDefinition$0(state) || MethodDefinition$1(state) || MethodDefinition$2(state) || MethodDefinition$3(state) || MethodDefinition$4(state) || MethodDefinition$5(state);
1899
1911
  }
1900
1912
  }
1913
+ var MethodModifier$0 = $S($C($EXPECT($L39, fail, 'MethodModifier "get"'), $EXPECT($L40, fail, 'MethodModifier "set"')), NonIdContinue, $Q(TrailingComment));
1914
+ function MethodModifier(state) {
1915
+ if (state.verbose)
1916
+ console.log("ENTER:", "MethodModifier");
1917
+ if (state.tokenize) {
1918
+ return $TOKEN("MethodModifier", state, MethodModifier$0(state));
1919
+ } else {
1920
+ return MethodModifier$0(state);
1921
+ }
1922
+ }
1923
+ var MethodSignature$0 = $S($E(MethodModifier), ClassElementName, $Q(_), Parameters);
1924
+ function MethodSignature(state) {
1925
+ if (state.verbose)
1926
+ console.log("ENTER:", "MethodSignature");
1927
+ if (state.tokenize) {
1928
+ return $TOKEN("MethodSignature", state, MethodSignature$0(state));
1929
+ } else {
1930
+ return MethodSignature$0(state);
1931
+ }
1932
+ }
1901
1933
  var ClassElementName$0 = PropertyName;
1902
1934
  var ClassElementName$1 = PrivateIdentifier;
1903
1935
  function ClassElementName(state) {
@@ -3312,17 +3344,65 @@ var Civet = (() => {
3312
3344
  return JSXChildExpression$0(state);
3313
3345
  }
3314
3346
  }
3315
- var TypeDeclaration$0 = $T($S($EXPECT($R30, fail, "TypeDeclaration /type(?!\\p{ID_Continue})/"), $Q(TrailingComment), IdentifierName, $E(TypeParameters), __, $EXPECT($L56, fail, 'TypeDeclaration "="'), __, Type), function(value) {
3316
- return { "ts": true, "children": value };
3317
- });
3318
- var TypeDeclaration$1 = $T($S($EXPECT($R31, fail, "TypeDeclaration /interface(?!\\p{ID_Continue})/"), $Q(TrailingComment), IdentifierName, InterfaceBlock), function(value) {
3347
+ var TypeDeclaration$0 = $T($S($Q($S(TypeDeclarationModifier, $Q(TrailingComment))), TypeDeclarationRest), function(value) {
3319
3348
  return { "ts": true, "children": value };
3320
3349
  });
3321
3350
  function TypeDeclaration(state) {
3351
+ if (state.verbose)
3352
+ console.log("ENTER:", "TypeDeclaration");
3353
+ if (state.tokenize) {
3354
+ return $TOKEN("TypeDeclaration", state, TypeDeclaration$0(state));
3355
+ } else {
3356
+ return TypeDeclaration$0(state);
3357
+ }
3358
+ }
3359
+ var TypeDeclarationModifier$0 = $S($EXPECT($L128, fail, 'TypeDeclarationModifier "declare"'), NonIdContinue);
3360
+ var TypeDeclarationModifier$1 = $S($EXPECT($L113, fail, 'TypeDeclarationModifier "export"'), NonIdContinue);
3361
+ function TypeDeclarationModifier(state) {
3362
+ if (state.tokenize) {
3363
+ return $TOKEN("TypeDeclarationModifier", state, TypeDeclarationModifier$0(state) || TypeDeclarationModifier$1(state));
3364
+ } else {
3365
+ return TypeDeclarationModifier$0(state) || TypeDeclarationModifier$1(state);
3366
+ }
3367
+ }
3368
+ var TypeDeclarationRest$0 = $S(TypeKeyword, $Q(TrailingComment), IdentifierName, $E(TypeParameters), __, $EXPECT($L56, fail, 'TypeDeclarationRest "="'), __, Type);
3369
+ var TypeDeclarationRest$1 = $S(Interface, $Q(TrailingComment), IdentifierName, InterfaceBlock);
3370
+ var TypeDeclarationRest$2 = $S(Namespace, $Q(TrailingComment), IdentifierName, NamespaceBlock);
3371
+ function TypeDeclarationRest(state) {
3372
+ if (state.tokenize) {
3373
+ return $TOKEN("TypeDeclarationRest", state, TypeDeclarationRest$0(state) || TypeDeclarationRest$1(state) || TypeDeclarationRest$2(state));
3374
+ } else {
3375
+ return TypeDeclarationRest$0(state) || TypeDeclarationRest$1(state) || TypeDeclarationRest$2(state);
3376
+ }
3377
+ }
3378
+ var TypeKeyword$0 = $S($EXPECT($L129, fail, 'TypeKeyword "type"'), NonIdContinue);
3379
+ function TypeKeyword(state) {
3380
+ if (state.verbose)
3381
+ console.log("ENTER:", "TypeKeyword");
3382
+ if (state.tokenize) {
3383
+ return $TOKEN("TypeKeyword", state, TypeKeyword$0(state));
3384
+ } else {
3385
+ return TypeKeyword$0(state);
3386
+ }
3387
+ }
3388
+ var Interface$0 = $S($EXPECT($L130, fail, 'Interface "interface"'), NonIdContinue);
3389
+ function Interface(state) {
3390
+ if (state.verbose)
3391
+ console.log("ENTER:", "Interface");
3392
+ if (state.tokenize) {
3393
+ return $TOKEN("Interface", state, Interface$0(state));
3394
+ } else {
3395
+ return Interface$0(state);
3396
+ }
3397
+ }
3398
+ var Namespace$0 = $S($EXPECT($L131, fail, 'Namespace "namespace"'), NonIdContinue);
3399
+ function Namespace(state) {
3400
+ if (state.verbose)
3401
+ console.log("ENTER:", "Namespace");
3322
3402
  if (state.tokenize) {
3323
- return $TOKEN("TypeDeclaration", state, TypeDeclaration$0(state) || TypeDeclaration$1(state));
3403
+ return $TOKEN("Namespace", state, Namespace$0(state));
3324
3404
  } else {
3325
- return TypeDeclaration$0(state) || TypeDeclaration$1(state);
3405
+ return Namespace$0(state);
3326
3406
  }
3327
3407
  }
3328
3408
  var InterfaceBlock$0 = $S(__, $EXPECT($L12, fail, 'InterfaceBlock "{"'), EOS, NestedInterfaceProperties, __, $EXPECT($L13, fail, 'InterfaceBlock "}"'));
@@ -3361,13 +3441,12 @@ var Civet = (() => {
3361
3441
  }
3362
3442
  }
3363
3443
  var InterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), TypeSuffix, InterfacePropertyDelimiter);
3444
+ var InterfaceProperty$1 = $S(MethodSignature, $E(TypeSuffix));
3364
3445
  function InterfaceProperty(state) {
3365
- if (state.verbose)
3366
- console.log("ENTER:", "InterfaceProperty");
3367
3446
  if (state.tokenize) {
3368
- return $TOKEN("InterfaceProperty", state, InterfaceProperty$0(state));
3447
+ return $TOKEN("InterfaceProperty", state, InterfaceProperty$0(state) || InterfaceProperty$1(state));
3369
3448
  } else {
3370
- return InterfaceProperty$0(state);
3449
+ return InterfaceProperty$0(state) || InterfaceProperty$1(state);
3371
3450
  }
3372
3451
  }
3373
3452
  var InterfacePropertyDelimiter$0 = $S($Q(_), $EXPECT($L88, fail, 'InterfacePropertyDelimiter ";"'));
@@ -3385,7 +3464,42 @@ var Civet = (() => {
3385
3464
  return InterfacePropertyDelimiter$0(state) || InterfacePropertyDelimiter$1(state) || InterfacePropertyDelimiter$2(state) || InterfacePropertyDelimiter$3(state);
3386
3465
  }
3387
3466
  }
3388
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R32, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L128, fail, 'TypeIndexSignature "readonly"'), __)), $EXPECT($L26, fail, 'TypeIndexSignature "["'), TypeIndex, $EXPECT($L27, fail, 'TypeIndexSignature "]"'), $E($S(__, $R$0($EXPECT($R33, fail, "TypeIndexSignature /[+-]/")), $EXPECT($L3, fail, 'TypeIndexSignature "?"'))));
3467
+ var NamespaceBlock$0 = $S(__, $EXPECT($L12, fail, 'NamespaceBlock "{"'), EOS, NestedTypeDeclarations, __, $EXPECT($L13, fail, 'NamespaceBlock "}"'));
3468
+ var NamespaceBlock$1 = $S(__, $EXPECT($L12, fail, 'NamespaceBlock "{"'), $Q($S(__, TypeDeclaration, InterfacePropertyDelimiter)), __, $EXPECT($L13, fail, 'NamespaceBlock "}"'));
3469
+ var NamespaceBlock$2 = $S(InsertOpenBrace, EOS, NestedTypeDeclarations, InsertNewline, InsertIndent, InsertCloseBrace);
3470
+ function NamespaceBlock(state) {
3471
+ if (state.tokenize) {
3472
+ return $TOKEN("NamespaceBlock", state, NamespaceBlock$0(state) || NamespaceBlock$1(state) || NamespaceBlock$2(state));
3473
+ } else {
3474
+ return NamespaceBlock$0(state) || NamespaceBlock$1(state) || NamespaceBlock$2(state);
3475
+ }
3476
+ }
3477
+ var NestedTypeDeclarations$0 = $TS($S(PushIndent, $Q(NestedTypeDeclaration), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
3478
+ var decs = $2;
3479
+ if (decs.length)
3480
+ return decs;
3481
+ return $skip;
3482
+ });
3483
+ function NestedTypeDeclarations(state) {
3484
+ if (state.verbose)
3485
+ console.log("ENTER:", "NestedTypeDeclarations");
3486
+ if (state.tokenize) {
3487
+ return $TOKEN("NestedTypeDeclarations", state, NestedTypeDeclarations$0(state));
3488
+ } else {
3489
+ return NestedTypeDeclarations$0(state);
3490
+ }
3491
+ }
3492
+ var NestedTypeDeclaration$0 = $S(Nested, TypeDeclaration, InterfacePropertyDelimiter);
3493
+ function NestedTypeDeclaration(state) {
3494
+ if (state.verbose)
3495
+ console.log("ENTER:", "NestedTypeDeclaration");
3496
+ if (state.tokenize) {
3497
+ return $TOKEN("NestedTypeDeclaration", state, NestedTypeDeclaration$0(state));
3498
+ } else {
3499
+ return NestedTypeDeclaration$0(state);
3500
+ }
3501
+ }
3502
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R30, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L132, fail, 'TypeIndexSignature "readonly"'), __)), $EXPECT($L26, fail, 'TypeIndexSignature "["'), TypeIndex, $EXPECT($L27, fail, 'TypeIndexSignature "]"'), $E($S(__, $R$0($EXPECT($R31, fail, "TypeIndexSignature /[+-]/")), $EXPECT($L3, fail, 'TypeIndexSignature "?"'))));
3389
3503
  function TypeIndexSignature(state) {
3390
3504
  if (state.verbose)
3391
3505
  console.log("ENTER:", "TypeIndexSignature");
@@ -3416,7 +3530,7 @@ var Civet = (() => {
3416
3530
  return TypeSuffix$0(state);
3417
3531
  }
3418
3532
  }
3419
- var ReturnTypeSuffix$0 = $T($S(__, $EXPECT($L14, fail, 'ReturnTypeSuffix ":"'), $E($S(__, $EXPECT($L129, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function(value) {
3533
+ var ReturnTypeSuffix$0 = $T($S(__, $EXPECT($L14, fail, 'ReturnTypeSuffix ":"'), $E($S(__, $EXPECT($L133, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function(value) {
3420
3534
  return { "ts": true, "children": value };
3421
3535
  });
3422
3536
  function ReturnTypeSuffix(state) {
@@ -3478,9 +3592,9 @@ var Civet = (() => {
3478
3592
  return TypeUnarySuffix$0(state);
3479
3593
  }
3480
3594
  }
3481
- var TypeUnaryOp$0 = $EXPECT($L130, fail, 'TypeUnaryOp "keyof"');
3595
+ var TypeUnaryOp$0 = $EXPECT($L134, fail, 'TypeUnaryOp "keyof"');
3482
3596
  var TypeUnaryOp$1 = $EXPECT($L85, fail, 'TypeUnaryOp "typeof"');
3483
- var TypeUnaryOp$2 = $EXPECT($L131, fail, 'TypeUnaryOp "infer"');
3597
+ var TypeUnaryOp$2 = $EXPECT($L135, fail, 'TypeUnaryOp "infer"');
3484
3598
  function TypeUnaryOp(state) {
3485
3599
  if (state.tokenize) {
3486
3600
  return $TOKEN("TypeUnaryOp", state, TypeUnaryOp$0(state) || TypeUnaryOp$1(state) || TypeUnaryOp$2(state));
@@ -3522,7 +3636,7 @@ var Civet = (() => {
3522
3636
  }
3523
3637
  var TypeLiteral$0 = Literal;
3524
3638
  var TypeLiteral$1 = $EXPECT($L84, fail, 'TypeLiteral "void"');
3525
- var TypeLiteral$2 = $EXPECT($L132, fail, 'TypeLiteral "[]"');
3639
+ var TypeLiteral$2 = $EXPECT($L136, fail, 'TypeLiteral "[]"');
3526
3640
  function TypeLiteral(state) {
3527
3641
  if (state.tokenize) {
3528
3642
  return $TOKEN("TypeLiteral", state, TypeLiteral$0(state) || TypeLiteral$1(state) || TypeLiteral$2(state));
@@ -3559,7 +3673,9 @@ var Civet = (() => {
3559
3673
  return TypeArguments$0(state);
3560
3674
  }
3561
3675
  }
3562
- var TypeParameters$0 = $S(__, $EXPECT($L16, fail, 'TypeParameters "<"'), __, Type, $Q($S(__, $EXPECT($L0, fail, 'TypeParameters ","'), __, Type)), $E($S(__, $EXPECT($L0, fail, 'TypeParameters ","'))), __, $EXPECT($L67, fail, 'TypeParameters ">"'));
3676
+ var TypeParameters$0 = $TS($S(__, $EXPECT($L16, fail, 'TypeParameters "<"'), __, Type, $Q($S(__, $EXPECT($L0, fail, 'TypeParameters ","'), __, Type)), $E($S(__, $EXPECT($L0, fail, 'TypeParameters ","'))), __, $EXPECT($L67, fail, 'TypeParameters ">"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
3677
+ return { ts: true, children: $0 };
3678
+ });
3563
3679
  function TypeParameters(state) {
3564
3680
  if (state.verbose)
3565
3681
  console.log("ENTER:", "TypeParameters");
@@ -3604,7 +3720,7 @@ var Civet = (() => {
3604
3720
  return TypeParameterDelimiter$0(state) || TypeParameterDelimiter$1(state) || TypeParameterDelimiter$2(state) || TypeParameterDelimiter$3(state);
3605
3721
  }
3606
3722
  }
3607
- var Shebang$0 = $R$0($EXPECT($R34, fail, "Shebang /#![^\\r\\n]*/"));
3723
+ var Shebang$0 = $R$0($EXPECT($R32, fail, "Shebang /#![^\\r\\n]*/"));
3608
3724
  function Shebang(state) {
3609
3725
  if (state.verbose)
3610
3726
  console.log("ENTER:", "Shebang");
@@ -3614,7 +3730,7 @@ var Civet = (() => {
3614
3730
  return Shebang$0(state);
3615
3731
  }
3616
3732
  }
3617
- var DirectivePrologue$0 = $TV($Q($S($TEXT($EXPECT($R35, fail, "DirectivePrologue /[\\t ]*/")), $TEXT(StringLiteral), $TEXT(StatementDelimiter), $TEXT(EOS))), function($skip, $loc, $0, $1) {
3733
+ var DirectivePrologue$0 = $TV($Q($S($TEXT($EXPECT($R33, fail, "DirectivePrologue /[\\t ]*/")), $TEXT(StringLiteral), $TEXT(StatementDelimiter), $TEXT(EOS))), function($skip, $loc, $0, $1) {
3618
3734
  return $0.map((p) => p.join(""));
3619
3735
  });
3620
3736
  function DirectivePrologue(state) {
@@ -3636,7 +3752,7 @@ var Civet = (() => {
3636
3752
  return EOS$0(state);
3637
3753
  }
3638
3754
  }
3639
- var EOL$0 = $R$0($EXPECT($R36, fail, "EOL /\\r\\n|\\n|\\r|$/"));
3755
+ var EOL$0 = $R$0($EXPECT($R34, fail, "EOL /\\r\\n|\\n|\\r|$/"));
3640
3756
  function EOL(state) {
3641
3757
  if (state.verbose)
3642
3758
  console.log("ENTER:", "EOL");
@@ -3646,7 +3762,7 @@ var Civet = (() => {
3646
3762
  return EOL$0(state);
3647
3763
  }
3648
3764
  }
3649
- var EOF$0 = $R$0($EXPECT($R37, fail, "EOF /$/"));
3765
+ var EOF$0 = $R$0($EXPECT($R35, fail, "EOF /$/"));
3650
3766
  function EOF(state) {
3651
3767
  if (state.verbose)
3652
3768
  console.log("ENTER:", "EOF");
@@ -3804,7 +3920,7 @@ var Civet = (() => {
3804
3920
  return Init$0(state);
3805
3921
  }
3806
3922
  }
3807
- var Indent$0 = $TV($Q($C($EXPECT($L133, fail, 'Indent " "'), $EXPECT($L134, fail, 'Indent "\\\\t"'))), function($skip, $loc, $0, $1) {
3923
+ var Indent$0 = $TV($Q($C($EXPECT($L137, fail, 'Indent " "'), $EXPECT($L138, fail, 'Indent "\\\\t"'))), function($skip, $loc, $0, $1) {
3808
3924
  return $1.length;
3809
3925
  });
3810
3926
  function Indent(state) {