Hex Artifact Content
Not logged in

Artifact 2739b95337ae2aab23af3854d431705e06e08dea:


0000: 2f 2a 2a 0d 0a 20 2a 20 41 75 74 68 6f 72 73 3a  /**.. * Authors:
0010: 20 6b 2e 69 6e 61 62 61 0d 0a 20 2a 20 4c 69 63   k.inaba.. * Lic
0020: 65 6e 73 65 3a 20 4e 59 53 4c 20 30 2e 39 39 38  ense: NYSL 0.998
0030: 32 20 68 74 74 70 3a 2f 2f 77 77 77 2e 6b 6d 6f  2 http://www.kmo
0040: 6e 6f 73 2e 6e 65 74 2f 6e 79 73 6c 2f 0d 0a 20  nos.net/nysl/.. 
0050: 2a 0d 0a 20 2a 20 50 61 72 73 65 72 20 66 6f 72  *.. * Parser for
0060: 20 50 6f 6c 65 6d 79 20 70 72 6f 67 72 61 6d 6d   Polemy programm
0070: 69 6e 67 20 6c 61 6e 67 75 61 67 65 0d 0a 20 2a  ing language.. *
0080: 2f 0d 0a 6d 6f 64 75 6c 65 20 70 6f 6c 65 6d 79  /..module polemy
0090: 2e 70 61 72 73 65 3b 0d 0a 69 6d 70 6f 72 74 20  .parse;..import 
00a0: 70 6f 6c 65 6d 79 2e 5f 63 6f 6d 6d 6f 6e 3b 0d  polemy._common;.
00b0: 0a 69 6d 70 6f 72 74 20 70 6f 6c 65 6d 79 2e 6c  .import polemy.l
00c0: 65 78 3b 0d 0a 69 6d 70 6f 72 74 20 70 6f 6c 65  ex;..import pole
00d0: 6d 79 2e 61 73 74 3b 0d 0a 0d 0a 2f 2f 2f 0d 0a  my.ast;....///..
00e0: 63 6c 61 73 73 20 50 61 72 73 65 45 78 63 65 70  class ParseExcep
00f0: 74 69 6f 6e 20 3a 20 45 78 63 65 70 74 69 6f 6e  tion : Exception
0100: 0d 0a 7b 0d 0a 09 6d 69 78 69 6e 20 45 78 63 65  ..{...mixin Exce
0110: 70 74 69 6f 6e 57 69 74 68 50 6f 73 69 74 69 6f  ptionWithPositio
0120: 6e 3b 0d 0a 7d 0d 0a 0d 0a 2f 2f 2f 20 45 6e 74  n;..}..../// Ent
0130: 72 79 20 70 6f 69 6e 74 73 20 6f 66 20 74 68 69  ry points of thi
0140: 73 20 6d 6f 64 75 6c 65 0d 0a 0d 0a 41 53 54 20  s module....AST 
0150: 70 61 72 73 65 53 74 72 69 6e 67 28 53 2c 20 54  parseString(S, T
0160: 2e 2e 2e 29 28 53 20 73 74 72 2c 20 54 20 66 6e  ...)(S str, T fn
0170: 5f 6c 6e 5f 63 6e 29 0d 0a 09 7b 20 72 65 74 75  _ln_cn)...{ retu
0180: 72 6e 20 70 61 72 73 65 72 46 72 6f 6d 53 74 72  rn parserFromStr
0190: 69 6e 67 28 73 74 72 2c 20 66 6e 5f 6c 6e 5f 63  ing(str, fn_ln_c
01a0: 6e 29 2e 70 61 72 73 65 28 29 3b 20 7d 0d 0a 0d  n).parse(); }...
01b0: 0a 2f 2f 2f 20 45 6e 74 72 79 20 70 6f 69 6e 74  ./// Entry point
01c0: 73 20 6f 66 20 74 68 69 73 20 6d 6f 64 75 6c 65  s of this module
01d0: 0d 0a 0d 0a 41 53 54 20 70 61 72 73 65 46 69 6c  ....AST parseFil
01e0: 65 28 53 2c 20 54 2e 2e 2e 29 28 53 20 66 69 6c  e(S, T...)(S fil
01f0: 65 6e 61 6d 65 2c 20 54 20 6c 6e 5f 63 6e 29 0d  ename, T ln_cn).
0200: 0a 09 7b 20 72 65 74 75 72 6e 20 70 61 72 73 65  ..{ return parse
0210: 72 46 72 6f 6d 46 69 6c 65 28 66 69 6c 65 6e 61  rFromFile(filena
0220: 6d 65 2c 20 6c 6e 5f 63 6e 29 2e 70 61 72 73 65  me, ln_cn).parse
0230: 28 29 3b 20 7d 0d 0a 0d 0a 2f 2f 20 4e 61 6d 65  (); }....// Name
0240: 64 20 43 6f 6e 73 74 72 75 63 74 6f 72 73 20 6f  d Constructors o
0250: 66 20 50 61 72 73 65 72 0d 0a 0d 0a 70 72 69 76  f Parser....priv
0260: 61 74 65 20 61 75 74 6f 20 70 61 72 73 65 72 46  ate auto parserF
0270: 72 6f 6d 4c 65 78 65 72 28 4c 65 78 65 72 29 28  romLexer(Lexer)(
0280: 4c 65 78 65 72 20 6c 65 78 29 0d 0a 09 7b 20 72  Lexer lex)...{ r
0290: 65 74 75 72 6e 20 6e 65 77 20 50 61 72 73 65 72  eturn new Parser
02a0: 21 4c 65 78 65 72 28 6c 65 78 29 3b 20 7d 0d 0a  !Lexer(lex); }..
02b0: 0d 0a 70 72 69 76 61 74 65 20 61 75 74 6f 20 70  ..private auto p
02c0: 61 72 73 65 72 46 72 6f 6d 53 74 72 69 6e 67 28  arserFromString(
02d0: 54 2e 2e 2e 29 28 54 20 70 61 72 61 6d 73 29 0d  T...)(T params).
02e0: 0a 09 7b 20 72 65 74 75 72 6e 20 70 61 72 73 65  ..{ return parse
02f0: 72 46 72 6f 6d 4c 65 78 65 72 28 70 6f 6c 65 6d  rFromLexer(polem
0300: 79 2e 6c 65 78 2e 6c 65 78 65 72 46 72 6f 6d 53  y.lex.lexerFromS
0310: 74 72 69 6e 67 28 70 61 72 61 6d 73 29 29 3b 20  tring(params)); 
0320: 7d 0d 0a 0d 0a 70 72 69 76 61 74 65 20 61 75 74  }....private aut
0330: 6f 20 70 61 72 73 65 72 46 72 6f 6d 46 69 6c 65  o parserFromFile
0340: 28 54 2e 2e 2e 29 28 54 20 70 61 72 61 6d 73 29  (T...)(T params)
0350: 0d 0a 09 7b 20 72 65 74 75 72 6e 20 70 61 72 73  ...{ return pars
0360: 65 72 46 72 6f 6d 4c 65 78 65 72 28 70 6f 6c 65  erFromLexer(pole
0370: 6d 79 2e 6c 65 78 2e 6c 65 78 65 72 46 72 6f 6d  my.lex.lexerFrom
0380: 46 69 6c 65 28 70 61 72 61 6d 73 29 29 3b 20 7d  File(params)); }
0390: 0d 0a 0d 0a 2f 2f 20 50 61 72 73 65 72 0d 0a 0d  ....// Parser...
03a0: 0a 70 72 69 76 61 74 65 20 63 6c 61 73 73 20 50  .private class P
03b0: 61 72 73 65 72 28 4c 65 78 65 72 29 0d 0a 09 69  arser(Lexer)...i
03c0: 66 28 20 69 73 46 6f 72 77 61 72 64 52 61 6e 67  f( isForwardRang
03d0: 65 21 28 4c 65 78 65 72 29 20 26 26 20 69 73 28  e!(Lexer) && is(
03e0: 45 6c 65 6d 65 6e 74 54 79 70 65 21 28 4c 65 78  ElementType!(Lex
03f0: 65 72 29 20 3d 3d 20 54 6f 6b 65 6e 29 20 29 0d  er) == Token) ).
0400: 0a 7b 0d 0a 09 41 53 54 20 70 61 72 73 65 28 29  .{...AST parse()
0410: 0d 0a 09 7b 0d 0a 09 09 61 75 74 6f 20 65 20 3d  ...{....auto e =
0420: 20 42 6f 64 79 28 29 3b 0d 0a 09 09 69 66 28 20   Body();....if( 
0430: 21 6c 65 78 2e 65 6d 70 74 79 20 29 0d 0a 09 09  !lex.empty )....
0440: 09 74 68 72 6f 77 20 67 65 6e 65 78 21 50 61 72  .throw genex!Par
0450: 73 65 45 78 63 65 70 74 69 6f 6e 28 63 75 72 72  seException(curr
0460: 65 6e 74 50 6f 73 69 74 69 6f 6e 28 29 2c 20 22  entPosition(), "
0470: 70 61 72 73 69 6e 67 20 65 6e 64 65 64 20 62 75  parsing ended bu
0480: 74 20 73 6f 6d 65 20 74 6f 6b 65 6e 73 20 6c 65  t some tokens le
0490: 66 74 22 29 3b 0d 0a 09 09 72 65 74 75 72 6e 20  ft");....return 
04a0: 65 3b 0d 0a 09 7d 0d 0a 0d 0a 09 41 53 54 20 42  e;...}.....AST B
04b0: 6f 64 79 28 29 0d 0a 09 7b 0d 0a 09 09 69 66 28  ody()...{....if(
04c0: 20 6c 65 78 2e 65 6d 70 74 79 20 7c 7c 20 21 6c   lex.empty || !l
04d0: 65 78 2e 66 72 6f 6e 74 2e 71 75 6f 74 65 64 20  ex.front.quoted 
04e0: 26 26 20 5b 22 7d 22 2c 22 29 22 2c 22 5d 22 5d  && ["}",")","]"]
04f0: 2e 63 61 6e 46 69 6e 64 28 6c 65 78 2e 66 72 6f  .canFind(lex.fro
0500: 6e 74 2e 73 74 72 29 20 29 0d 0a 09 09 09 72 65  nt.str) ).....re
0510: 74 75 72 6e 20 64 6f 4e 6f 74 68 69 6e 67 45 78  turn doNothingEx
0520: 70 72 65 73 73 69 6f 6e 28 29 3b 0d 0a 0d 0a 09  pression();.....
0530: 09 61 75 74 6f 20 73 61 76 65 64 20 3d 20 6c 65  .auto saved = le
0540: 78 2e 73 61 76 65 3b 0d 0a 09 09 61 75 74 6f 20  x.save;....auto 
0550: 70 6f 73 20 3d 20 6c 65 78 2e 66 72 6f 6e 74 2e  pos = lex.front.
0560: 70 6f 73 3b 0d 0a 09 09 73 74 72 69 6e 67 20 6b  pos;....string k
0570: 77 64 20 3d 20 6c 65 78 2e 66 72 6f 6e 74 2e 73  wd = lex.front.s
0580: 74 72 3b 0d 0a 09 09 69 66 28 20 74 72 79 45 61  tr;....if( tryEa
0590: 74 28 22 6c 65 74 22 29 20 7c 7c 20 74 72 79 45  t("let") || tryE
05a0: 61 74 28 22 76 61 72 22 29 20 7c 7c 20 74 72 79  at("var") || try
05b0: 45 61 74 28 22 64 65 66 22 29 20 7c 7c 20 74 72  Eat("def") || tr
05c0: 79 45 61 74 28 22 40 22 29 20 29 0d 0a 09 09 7b  yEat("@") )....{
05d0: 0d 0a 09 09 09 69 66 28 20 6b 77 64 20 3d 3d 20  .....if( kwd == 
05e0: 22 40 22 20 29 20 7b 0d 0a 09 09 09 09 6b 77 64  "@" ) {......kwd
05f0: 20 7e 3d 20 65 61 74 49 64 28 22 61 66 74 65 72   ~= eatId("after
0600: 20 40 22 2c 74 72 75 65 29 3b 0d 0a 09 09 09 09   @",true);......
0610: 69 66 28 20 74 72 79 45 61 74 28 22 28 22 29 20  if( tryEat("(") 
0620: 29 20 7b 0d 0a 09 09 09 09 09 6c 65 78 20 3d 20  ) {.......lex = 
0630: 73 61 76 65 64 3b 0d 0a 09 09 09 09 09 67 6f 74  saved;.......got
0640: 6f 20 61 73 45 78 70 72 65 73 73 69 6f 6e 3b 0d  o asExpression;.
0650: 0a 09 09 09 09 7d 0d 0a 09 09 09 7d 0d 0a 09 09  .....}.....}....
0660: 09 69 6d 6d 75 74 61 62 6c 65 20 4c 65 78 50 6f  .immutable LexPo
0670: 73 69 74 69 6f 6e 20 76 61 72 70 6f 73 20 3d 20  sition varpos = 
0680: 28 6c 65 78 2e 65 6d 70 74 79 20 3f 20 6e 75 6c  (lex.empty ? nul
0690: 6c 20 3a 20 6c 65 78 2e 66 72 6f 6e 74 2e 70 6f  l : lex.front.po
06a0: 73 29 3b 0d 0a 09 09 09 73 74 72 69 6e 67 20 76  s);.....string v
06b0: 61 72 20 3d 20 65 61 74 49 64 28 22 61 66 74 65  ar = eatId("afte
06c0: 72 20 22 7e 6b 77 64 2c 74 72 75 65 29 3b 0d 0a  r "~kwd,true);..
06d0: 09 09 09 2f 2f 20 5b 54 4f 44 4f 5d 20 72 65 66  ...// [TODO] ref
06e0: 61 63 74 6f 72 2e 20 6f 6e 6c 79 20 61 75 74 6f  actor. only auto
06f0: 20 65 20 3d 20 2e 2e 2e 20 64 69 66 66 65 72 0d   e = ... differ.
0700: 0a 09 09 09 69 66 28 74 72 79 45 61 74 28 22 28  ....if(tryEat("(
0710: 22 29 29 20 7b 0d 0a 09 09 09 09 6b 77 64 20 3d  ")) {......kwd =
0720: 20 28 6b 77 64 5b 30 5d 3d 3d 27 40 27 20 3f 20   (kwd[0]=='@' ? 
0730: 6b 77 64 20 3a 20 22 22 29 3b 20 2f 2f 20 22 6c  kwd : ""); // "l
0740: 65 74 2c 20 76 61 72 2c 20 64 65 66 20 3d 3d 3e  et, var, def ==>
0750: 20 6e 65 75 74 72 61 6c 20 6c 61 79 65 72 22 0d   neutral layer".
0760: 0a 09 09 09 09 61 75 74 6f 20 65 20 3d 20 70 61  .....auto e = pa
0770: 72 73 65 4c 61 6d 62 64 61 41 66 74 65 72 4f 70  rseLambdaAfterOp
0780: 65 6e 50 61 72 65 6e 28 76 61 72 70 6f 73 29 3b  enParen(varpos);
0790: 0d 0a 09 09 09 09 69 66 28 20 74 72 79 45 61 74  ......if( tryEat
07a0: 28 22 3b 22 29 20 26 26 20 21 6c 65 78 2e 65 6d  (";") && !lex.em
07b0: 70 74 79 20 26 26 20 28 6c 65 78 2e 66 72 6f 6e  pty && (lex.fron
07c0: 74 2e 71 75 6f 74 65 64 20 7c 7c 20 21 5b 22 7d  t.quoted || !["}
07d0: 22 2c 22 29 22 2c 22 5d 22 5d 2e 63 61 6e 46 69  ",")","]"].canFi
07e0: 6e 64 28 6c 65 78 2e 66 72 6f 6e 74 2e 73 74 72  nd(lex.front.str
07f0: 29 29 20 29 0d 0a 09 09 09 09 09 72 65 74 75 72  )) ).......retur
0800: 6e 20 6e 65 77 20 4c 65 74 45 78 70 72 65 73 73  n new LetExpress
0810: 69 6f 6e 28 70 6f 73 2c 20 76 61 72 2c 20 6b 77  ion(pos, var, kw
0820: 64 2c 20 65 2c 20 42 6f 64 79 28 29 29 3b 0d 0a  d, e, Body());..
0830: 09 09 09 09 65 6c 73 65 0d 0a 09 09 09 09 09 72  ....else.......r
0840: 65 74 75 72 6e 20 6e 65 77 20 4c 65 74 45 78 70  eturn new LetExp
0850: 72 65 73 73 69 6f 6e 28 70 6f 73 2c 20 76 61 72  ression(pos, var
0860: 2c 20 6b 77 64 2c 20 65 2c 20 6e 65 77 20 56 61  , kwd, e, new Va
0870: 72 45 78 70 72 65 73 73 69 6f 6e 28 76 61 72 70  rExpression(varp
0880: 6f 73 2c 20 76 61 72 29 29 3b 0d 0a 09 09 09 7d  os, var));.....}
0890: 20 65 6c 73 65 20 7b 0d 0a 09 09 09 09 65 61 74   else {......eat
08a0: 28 22 3d 22 2c 20 22 61 66 74 65 72 20 22 7e 6b  ("=", "after "~k
08b0: 77 64 29 3b 0d 0a 09 09 09 09 6b 77 64 20 3d 20  wd);......kwd = 
08c0: 28 6b 77 64 5b 30 5d 3d 3d 27 40 27 20 3f 20 6b  (kwd[0]=='@' ? k
08d0: 77 64 20 3a 20 22 22 29 3b 20 2f 2f 20 22 6c 65  wd : ""); // "le
08e0: 74 2c 20 76 61 72 2c 20 64 65 66 20 3d 3d 3e 20  t, var, def ==> 
08f0: 6e 65 75 74 72 61 6c 20 6c 61 79 65 72 22 0d 0a  neutral layer"..
0900: 09 09 09 09 61 75 74 6f 20 65 20 3d 20 45 28 30  ....auto e = E(0
0910: 29 3b 0d 0a 09 09 09 09 69 66 28 20 74 72 79 45  );......if( tryE
0920: 61 74 28 22 3b 22 29 20 26 26 20 21 6c 65 78 2e  at(";") && !lex.
0930: 65 6d 70 74 79 20 26 26 20 28 6c 65 78 2e 66 72  empty && (lex.fr
0940: 6f 6e 74 2e 71 75 6f 74 65 64 20 7c 7c 20 21 5b  ont.quoted || ![
0950: 22 7d 22 2c 22 29 22 2c 22 5d 22 5d 2e 63 61 6e  "}",")","]"].can
0960: 46 69 6e 64 28 6c 65 78 2e 66 72 6f 6e 74 2e 73  Find(lex.front.s
0970: 74 72 29 29 20 29 0d 0a 09 09 09 09 09 72 65 74  tr)) ).......ret
0980: 75 72 6e 20 6e 65 77 20 4c 65 74 45 78 70 72 65  urn new LetExpre
0990: 73 73 69 6f 6e 28 70 6f 73 2c 20 76 61 72 2c 20  ssion(pos, var, 
09a0: 6b 77 64 2c 20 65 2c 20 42 6f 64 79 28 29 29 3b  kwd, e, Body());
09b0: 0d 0a 09 09 09 09 65 6c 73 65 0d 0a 09 09 09 09  ......else......
09c0: 09 72 65 74 75 72 6e 20 6e 65 77 20 4c 65 74 45  .return new LetE
09d0: 78 70 72 65 73 73 69 6f 6e 28 70 6f 73 2c 20 76  xpression(pos, v
09e0: 61 72 2c 20 6b 77 64 2c 20 65 2c 20 6e 65 77 20  ar, kwd, e, new 
09f0: 56 61 72 45 78 70 72 65 73 73 69 6f 6e 28 76 61  VarExpression(va
0a00: 72 70 6f 73 2c 20 76 61 72 29 29 3b 0d 0a 09 09  rpos, var));....
0a10: 09 7d 0d 0a 09 09 7d 0d 0a 09 09 65 6c 73 65 0d  .}....}....else.
0a20: 0a 09 09 7b 0d 0a 09 09 61 73 45 78 70 72 65 73  ...{....asExpres
0a30: 73 69 6f 6e 3a 0d 0a 09 09 09 61 75 74 6f 20 65  sion:.....auto e
0a40: 20 3d 20 45 28 30 29 3b 0d 0a 09 09 09 69 66 28   = E(0);.....if(
0a50: 20 74 72 79 45 61 74 28 22 3b 22 29 20 26 26 20   tryEat(";") && 
0a60: 21 6c 65 78 2e 65 6d 70 74 79 20 26 26 20 28 6c  !lex.empty && (l
0a70: 65 78 2e 66 72 6f 6e 74 2e 71 75 6f 74 65 64 20  ex.front.quoted 
0a80: 7c 7c 20 28 6c 65 78 2e 66 72 6f 6e 74 2e 73 74  || (lex.front.st
0a90: 72 21 3d 22 7d 22 20 26 26 20 6c 65 78 2e 66 72  r!="}" && lex.fr
0aa0: 6f 6e 74 2e 73 74 72 21 3d 22 29 22 29 29 20 29  ont.str!=")")) )
0ab0: 0d 0a 09 09 09 09 72 65 74 75 72 6e 20 6e 65 77  ......return new
0ac0: 20 4c 65 74 45 78 70 72 65 73 73 69 6f 6e 28 70   LetExpression(p
0ad0: 6f 73 2c 20 22 5f 22 2c 20 22 22 2c 20 65 2c 20  os, "_", "", e, 
0ae0: 42 6f 64 79 28 29 29 3b 0d 0a 09 09 09 65 6c 73  Body());.....els
0af0: 65 0d 0a 09 09 09 09 72 65 74 75 72 6e 20 65 3b  e......return e;
0b00: 0d 0a 09 09 7d 0d 0a 09 7d 0d 0a 0d 0a 09 2f 2f  ....}...}.....//
0b10: 20 5b 54 4f 44 4f 5d 20 6d 61 6b 65 20 63 75 73   [TODO] make cus
0b20: 74 6f 6d 69 7a 61 62 6c 65 20 66 72 6f 6d 20 70  tomizable from p
0b30: 72 6f 67 72 61 6d 0d 0a 09 73 74 61 74 69 63 20  rogram...static 
0b40: 69 6d 6d 75 74 61 62 6c 65 20 73 74 72 69 6e 67  immutable string
0b50: 5b 5d 5b 5d 20 6f 70 65 72 61 74 6f 72 5f 70 65  [][] operator_pe
0b60: 72 66 65 72 65 6e 63 65 73 20 3d 20 5b 0d 0a 09  rferences = [...
0b70: 09 5b 22 7c 7c 22 5d 2c 0d 0a 09 09 5b 22 26 26  .["||"],....["&&
0b80: 22 5d 2c 0d 0a 09 09 5b 22 21 3d 22 5d 2c 0d 0a  "],....["!="],..
0b90: 09 09 5b 22 3d 3d 22 5d 2c 0d 0a 09 09 5b 22 3c  ..["=="],....["<
0ba0: 22 2c 22 3c 3d 22 2c 22 3e 22 2c 22 3e 3d 22 5d  ","<=",">",">="]
0bb0: 2c 0d 0a 09 09 5b 22 7c 22 5d 2c 0d 0a 09 09 5b  ,....["|"],....[
0bc0: 22 5e 22 5d 2c 0d 0a 09 09 5b 22 26 22 5d 2c 0d  "^"],....["&"],.
0bd0: 0a 09 09 5b 22 3c 3c 22 2c 20 22 3e 3e 22 5d 2c  ...["<<", ">>"],
0be0: 0d 0a 09 09 5b 22 2b 22 2c 22 2d 22 5d 2c 0d 0a  ....["+","-"],..
0bf0: 09 09 5b 22 7e 22 5d 2c 0d 0a 09 09 5b 22 2a 22  ..["~"],....["*"
0c00: 2c 22 2f 22 2c 22 25 22 5d 2c 0d 0a 09 09 5b 22  ,"/","%"],....["
0c10: 5e 5e 22 5d 0d 0a 09 5d 3b 0d 0a 0d 0a 09 41 53  ^^"]...];.....AS
0c20: 54 20 45 28 69 6e 74 20 6c 65 76 65 6c 29 0d 0a  T E(int level)..
0c30: 09 7b 0d 0a 09 09 69 66 28 20 6f 70 65 72 61 74  .{....if( operat
0c40: 6f 72 5f 70 65 72 66 65 72 65 6e 63 65 73 2e 6c  or_perferences.l
0c50: 65 6e 67 74 68 20 3c 3d 20 6c 65 76 65 6c 20 29  ength <= level )
0c60: 0d 0a 09 09 09 72 65 74 75 72 6e 20 46 75 6e 63  .....return Func
0c70: 61 6c 6c 28 29 3b 0d 0a 09 09 65 6c 73 65 0d 0a  all();....else..
0c80: 09 09 7b 0d 0a 09 09 09 61 75 74 6f 20 6f 70 73  ..{.....auto ops
0c90: 20 3d 20 6f 70 65 72 61 74 6f 72 5f 70 65 72 66   = operator_perf
0ca0: 65 72 65 6e 63 65 73 5b 6c 65 76 65 6c 5d 3b 0d  erences[level];.
0cb0: 0a 09 09 09 61 75 74 6f 20 65 20 3d 20 45 28 6c  ....auto e = E(l
0cc0: 65 76 65 6c 2b 31 29 3b 0d 0a 09 09 73 65 71 3a  evel+1);....seq:
0cd0: 0d 0a 09 09 09 77 68 69 6c 65 28 20 21 6c 65 78  .....while( !lex
0ce0: 2e 65 6d 70 74 79 20 29 0d 0a 09 09 09 7b 0d 0a  .empty ).....{..
0cf0: 09 09 09 09 61 75 74 6f 20 70 6f 73 20 3d 20 6c  ....auto pos = l
0d00: 65 78 2e 66 72 6f 6e 74 2e 70 6f 73 3b 0d 0a 09  ex.front.pos;...
0d10: 09 09 09 66 6f 72 65 61 63 68 28 6f 70 3b 20 6f  ...foreach(op; o
0d20: 70 73 29 0d 0a 09 09 09 09 09 69 66 28 20 74 72  ps).......if( tr
0d30: 79 45 61 74 28 6f 70 29 20 29 0d 0a 09 09 09 09  yEat(op) )......
0d40: 09 7b 0d 0a 09 09 09 09 09 09 65 20 3d 20 6e 65  .{........e = ne
0d50: 77 20 46 75 6e 63 61 6c 6c 45 78 70 72 65 73 73  w FuncallExpress
0d60: 69 6f 6e 28 65 2e 70 6f 73 2c 20 6e 65 77 20 56  ion(e.pos, new V
0d70: 61 72 45 78 70 72 65 73 73 69 6f 6e 28 70 6f 73  arExpression(pos
0d80: 2c 20 6f 70 29 2c 20 65 2c 20 45 28 6c 65 76 65  , op), e, E(leve
0d90: 6c 2b 31 29 29 3b 0d 0a 09 09 09 09 09 09 63 6f  l+1));........co
0da0: 6e 74 69 6e 75 65 20 73 65 71 3b 0d 0a 09 09 09  ntinue seq;.....
0db0: 09 09 7d 0d 0a 09 09 09 09 62 72 65 61 6b 3b 0d  ..}......break;.
0dc0: 0a 09 09 09 7d 0d 0a 09 09 09 72 65 74 75 72 6e  ....}.....return
0dd0: 20 65 3b 0d 0a 09 09 7d 0d 0a 09 7d 0d 0a 0d 0a   e;....}...}....
0de0: 09 41 53 54 20 46 75 6e 63 61 6c 6c 28 29 0d 0a  .AST Funcall()..
0df0: 09 7b 0d 0a 09 09 61 75 74 6f 20 65 20 3d 20 42  .{....auto e = B
0e00: 61 73 65 45 78 70 72 65 73 73 69 6f 6e 28 29 3b  aseExpression();
0e10: 0d 0a 09 09 77 68 69 6c 65 28 20 74 72 79 45 61  ....while( tryEa
0e20: 74 28 22 28 22 29 20 29 0d 0a 09 09 7b 0d 0a 09  t("(") )....{...
0e30: 09 09 61 75 74 6f 20 70 6f 73 20 3d 20 63 75 72  ..auto pos = cur
0e40: 72 65 6e 74 50 6f 73 69 74 69 6f 6e 28 29 3b 0d  rentPosition();.
0e50: 0a 09 09 09 41 53 54 5b 5d 20 61 72 67 73 3b 0d  ....AST[] args;.
0e60: 0a 09 09 09 77 68 69 6c 65 28 20 21 74 72 79 45  ....while( !tryE
0e70: 61 74 28 22 29 22 29 20 29 20 7b 0d 0a 09 09 09  at(")") ) {.....
0e80: 09 69 66 28 20 6c 65 78 2e 65 6d 70 74 79 20 29  .if( lex.empty )
0e90: 0d 0a 09 09 09 09 09 74 68 72 6f 77 20 67 65 6e  .......throw gen
0ea0: 65 78 21 55 6e 65 78 70 65 63 74 65 64 45 4f 46  ex!UnexpectedEOF
0eb0: 28 70 6f 73 2c 22 43 6c 6f 73 69 6e 67 20 27 29  (pos,"Closing ')
0ec0: 27 20 66 6f 72 20 61 72 67 75 6d 65 6e 74 73 20  ' for arguments 
0ed0: 6e 6f 74 20 66 6f 75 6e 64 22 29 3b 0d 0a 09 09  not found");....
0ee0: 09 09 61 72 67 73 20 7e 3d 20 45 28 30 29 3b 0d  ..args ~= E(0);.
0ef0: 0a 09 09 09 09 69 66 28 20 21 74 72 79 45 61 74  .....if( !tryEat
0f00: 28 22 2c 22 29 20 29 20 7b 0d 0a 09 09 09 09 09  (",") ) {.......
0f10: 65 61 74 28 22 29 22 2c 20 22 61 66 74 65 72 20  eat(")", "after 
0f20: 66 75 6e 63 74 69 6f 6e 20 70 61 72 61 6d 65 74  function paramet
0f30: 65 72 73 22 29 3b 0d 0a 09 09 09 09 09 62 72 65  ers");.......bre
0f40: 61 6b 3b 0d 0a 09 09 09 09 7d 0d 0a 09 09 09 7d  ak;......}.....}
0f50: 0d 0a 09 09 09 65 20 3d 20 6e 65 77 20 46 75 6e  .....e = new Fun
0f60: 63 61 6c 6c 45 78 70 72 65 73 73 69 6f 6e 28 65  callExpression(e
0f70: 2e 70 6f 73 2c 20 65 2c 20 61 72 67 73 29 3b 0d  .pos, e, args);.
0f80: 0a 09 09 7d 0d 0a 09 09 72 65 74 75 72 6e 20 65  ...}....return e
0f90: 3b 0d 0a 09 7d 0d 0a 0d 0a 09 41 53 54 20 42 61  ;...}.....AST Ba
0fa0: 73 65 45 78 70 72 65 73 73 69 6f 6e 28 29 0d 0a  seExpression()..
0fb0: 09 7b 0d 0a 09 09 69 66 28 20 6c 65 78 2e 65 6d  .{....if( lex.em
0fc0: 70 74 79 20 29 0d 0a 09 09 09 74 68 72 6f 77 20  pty ).....throw 
0fd0: 67 65 6e 65 78 21 55 6e 65 78 70 65 63 74 65 64  genex!Unexpected
0fe0: 45 4f 46 28 63 75 72 72 65 6e 74 50 6f 73 69 74  EOF(currentPosit
0ff0: 69 6f 6e 28 29 2c 20 22 52 65 61 63 68 65 64 20  ion(), "Reached 
1000: 45 4f 46 20 77 68 65 6e 20 74 72 69 65 64 20 74  EOF when tried t
1010: 6f 20 70 61 72 73 65 20 61 6e 20 65 78 70 72 65  o parse an expre
1020: 73 73 69 6f 6e 22 29 3b 0d 0a 0d 0a 09 09 61 75  ssion");......au
1030: 74 6f 20 70 6f 73 20 3d 20 6c 65 78 2e 66 72 6f  to pos = lex.fro
1040: 6e 74 2e 70 6f 73 3b 0d 0a 09 09 69 66 28 20 6c  nt.pos;....if( l
1050: 65 78 2e 66 72 6f 6e 74 2e 71 75 6f 74 65 64 20  ex.front.quoted 
1060: 29 0d 0a 09 09 7b 0d 0a 09 09 09 73 63 6f 70 65  )....{.....scope
1070: 28 65 78 69 74 29 20 6c 65 78 2e 70 6f 70 46 72  (exit) lex.popFr
1080: 6f 6e 74 3b 0d 0a 09 09 09 72 65 74 75 72 6e 20  ont;.....return 
1090: 6e 65 77 20 53 74 72 4c 69 74 65 72 61 6c 28 70  new StrLiteral(p
10a0: 6f 73 2c 20 6c 65 78 2e 66 72 6f 6e 74 2e 73 74  os, lex.front.st
10b0: 72 29 3b 0d 0a 09 09 7d 0d 0a 09 09 69 66 28 20  r);....}....if( 
10c0: 69 73 4e 75 6d 62 65 72 28 6c 65 78 2e 66 72 6f  isNumber(lex.fro
10d0: 6e 74 2e 73 74 72 29 20 29 0d 0a 09 09 7b 0d 0a  nt.str) )....{..
10e0: 09 09 09 73 63 6f 70 65 28 65 78 69 74 29 20 6c  ...scope(exit) l
10f0: 65 78 2e 70 6f 70 46 72 6f 6e 74 3b 0d 0a 09 09  ex.popFront;....
1100: 09 72 65 74 75 72 6e 20 6e 65 77 20 49 6e 74 4c  .return new IntL
1110: 69 74 65 72 61 6c 28 70 6f 73 2c 20 42 69 67 49  iteral(pos, BigI
1120: 6e 74 28 63 61 73 74 28 73 74 72 69 6e 67 29 6c  nt(cast(string)l
1130: 65 78 2e 66 72 6f 6e 74 2e 73 74 72 29 29 3b 0d  ex.front.str));.
1140: 0a 09 09 7d 0d 0a 09 09 69 66 28 20 74 72 79 45  ...}....if( tryE
1150: 61 74 28 22 40 22 29 20 29 0d 0a 09 09 7b 0d 0a  at("@") )....{..
1160: 09 09 09 61 75 74 6f 20 6c 61 79 20 3d 20 22 40  ...auto lay = "@
1170: 22 7e 65 61 74 49 64 28 22 66 6f 72 20 6c 61 79  "~eatId("for lay
1180: 65 72 20 49 44 22 29 3b 0d 0a 09 09 09 65 61 74  er ID");.....eat
1190: 28 22 28 22 2c 20 22 66 6f 72 20 6c 61 79 65 72  ("(", "for layer
11a0: 65 64 20 65 78 65 63 75 74 69 6f 6e 22 29 3b 0d  ed execution");.
11b0: 0a 09 09 09 61 75 74 6f 20 65 20 3d 20 42 6f 64  ....auto e = Bod
11c0: 79 28 29 3b 0d 0a 09 09 09 65 61 74 28 22 29 22  y();.....eat(")"
11d0: 2c 20 22 61 66 74 65 72 20 22 7e 6c 61 79 7e 22  , "after "~lay~"
11e0: 28 2e 2e 2e 22 29 3b 0d 0a 09 09 09 72 65 74 75  (...");.....retu
11f0: 72 6e 20 6e 65 77 20 4c 61 79 65 72 65 64 45 78  rn new LayeredEx
1200: 70 72 65 73 73 69 6f 6e 28 70 6f 73 2c 20 6c 61  pression(pos, la
1210: 79 2c 20 65 29 3b 0d 0a 09 09 7d 0d 0a 09 09 69  y, e);....}....i
1220: 66 28 20 74 72 79 45 61 74 28 22 28 22 29 20 29  f( tryEat("(") )
1230: 0d 0a 09 09 7b 0d 0a 09 09 09 61 75 74 6f 20 65  ....{.....auto e
1240: 20 3d 20 42 6f 64 79 28 29 3b 0d 0a 09 09 09 65   = Body();.....e
1250: 61 74 28 22 29 22 2c 20 22 61 66 74 65 72 20 70  at(")", "after p
1260: 61 72 65 6e 74 68 65 73 69 7a 65 64 20 65 78 70  arenthesized exp
1270: 72 65 73 73 69 6f 6e 22 29 3b 0d 0a 09 09 09 72  ression");.....r
1280: 65 74 75 72 6e 20 65 3b 0d 0a 09 09 7d 0d 0a 09  eturn e;....}...
1290: 09 69 66 28 20 74 72 79 45 61 74 28 22 69 66 22  .if( tryEat("if"
12a0: 29 20 29 0d 0a 09 09 7b 0d 0a 09 09 09 65 61 74  ) )....{.....eat
12b0: 28 22 28 22 2c 20 22 61 66 74 65 72 20 69 66 22  ("(", "after if"
12c0: 29 3b 0d 0a 09 09 09 61 75 74 6f 20 63 6f 6e 64  );.....auto cond
12d0: 20 3d 20 45 28 30 29 3b 0d 0a 09 09 09 65 61 74   = E(0);.....eat
12e0: 28 22 29 22 2c 20 22 61 66 74 65 72 20 69 66 20  (")", "after if 
12f0: 63 6f 6e 64 69 74 69 6f 6e 22 29 3b 0d 0a 09 09  condition");....
1300: 09 61 75 74 6f 20 74 68 65 6e 50 6f 73 20 3d 20  .auto thenPos = 
1310: 6c 65 78 2e 66 72 6f 6e 74 2e 70 6f 73 3b 0d 0a  lex.front.pos;..
1320: 09 09 09 65 61 74 28 22 7b 22 2c 20 22 61 66 74  ...eat("{", "aft
1330: 65 72 20 69 66 20 63 6f 6e 64 69 74 69 6f 6e 22  er if condition"
1340: 29 3b 0d 0a 09 09 09 61 75 74 6f 20 74 68 20 3d  );.....auto th =
1350: 20 42 6f 64 79 28 29 3b 0d 0a 09 09 09 65 61 74   Body();.....eat
1360: 28 22 7d 22 2c 20 22 61 66 74 65 72 20 69 66 2d  ("}", "after if-
1370: 74 68 65 6e 20 62 6f 64 79 22 29 3b 0d 0a 09 09  then body");....
1380: 09 61 75 74 6f 20 65 6c 20 3d 20 64 6f 4e 6f 74  .auto el = doNot
1390: 68 69 6e 67 45 78 70 72 65 73 73 69 6f 6e 28 29  hingExpression()
13a0: 3b 0d 0a 09 09 09 61 75 74 6f 20 65 6c 73 65 50  ;.....auto elseP
13b0: 6f 73 20 3d 20 28 6c 65 78 2e 65 6d 70 74 79 20  os = (lex.empty 
13c0: 3f 20 4c 65 78 50 6f 73 69 74 69 6f 6e 2e 64 75  ? LexPosition.du
13d0: 6d 6d 79 20 3a 20 6c 65 78 2e 66 72 6f 6e 74 2e  mmy : lex.front.
13e0: 70 6f 73 29 3b 0d 0a 09 09 09 69 66 28 20 74 72  pos);.....if( tr
13f0: 79 45 61 74 28 22 65 6c 73 65 22 29 20 29 20 7b  yEat("else") ) {
1400: 0d 0a 09 09 09 09 65 61 74 28 22 7b 22 2c 20 22  ......eat("{", "
1410: 61 66 74 65 72 20 65 6c 73 65 22 29 3b 0d 0a 09  after else");...
1420: 09 09 09 65 6c 20 3d 20 42 6f 64 79 28 29 3b 0d  ...el = Body();.
1430: 0a 09 09 09 09 65 61 74 28 22 7d 22 2c 20 22 61  .....eat("}", "a
1440: 66 74 65 72 20 65 6c 73 65 20 62 6f 64 79 22 29  fter else body")
1450: 3b 0d 0a 09 09 09 7d 0d 0a 09 09 09 72 65 74 75  ;.....}.....retu
1460: 72 6e 20 6e 65 77 20 46 75 6e 63 61 6c 6c 45 78  rn new FuncallEx
1470: 70 72 65 73 73 69 6f 6e 28 70 6f 73 2c 20 0d 0a  pression(pos, ..
1480: 09 09 09 09 6e 65 77 20 56 61 72 45 78 70 72 65  ....new VarExpre
1490: 73 73 69 6f 6e 28 70 6f 73 2c 20 22 69 66 22 29  ssion(pos, "if")
14a0: 2c 0d 0a 09 09 09 09 63 6f 6e 64 2c 0d 0a 09 09  ,......cond,....
14b0: 09 09 6e 65 77 20 46 75 6e 4c 69 74 65 72 61 6c  ..new FunLiteral
14c0: 28 74 68 65 6e 50 6f 73 2c 20 5b 5d 2c 20 74 68  (thenPos, [], th
14d0: 29 2c 0d 0a 09 09 09 09 6e 65 77 20 46 75 6e 4c  ),......new FunL
14e0: 69 74 65 72 61 6c 28 65 6c 73 65 50 6f 73 2c 20  iteral(elsePos, 
14f0: 5b 5d 2c 20 65 6c 29 0d 0a 09 09 09 29 3b 0d 0a  [], el).....);..
1500: 09 09 7d 0d 0a 09 09 69 66 28 20 74 72 79 45 61  ..}....if( tryEa
1510: 74 28 22 66 75 6e 22 29 20 7c 7c 20 74 72 79 45  t("fun") || tryE
1520: 61 74 28 22 5c 75 30 33 42 42 22 29 20 29 0d 0a  at("\u03BB") )..
1530: 09 09 7b 0d 0a 09 09 09 65 61 74 28 22 28 22 2c  ..{.....eat("(",
1540: 20 22 61 66 74 65 72 20 66 75 6e 22 29 3b 0d 0a   "after fun");..
1550: 09 09 09 72 65 74 75 72 6e 20 70 61 72 73 65 4c  ...return parseL
1560: 61 6d 62 64 61 41 66 74 65 72 4f 70 65 6e 50 61  ambdaAfterOpenPa
1570: 72 65 6e 28 70 6f 73 29 3b 0d 0a 09 09 7d 0d 0a  ren(pos);....}..
1580: 09 09 73 63 6f 70 65 28 65 78 69 74 29 20 6c 65  ..scope(exit) le
1590: 78 2e 70 6f 70 46 72 6f 6e 74 3b 0d 0a 09 09 72  x.popFront;....r
15a0: 65 74 75 72 6e 20 6e 65 77 20 56 61 72 45 78 70  eturn new VarExp
15b0: 72 65 73 73 69 6f 6e 28 70 6f 73 2c 20 6c 65 78  ression(pos, lex
15c0: 2e 66 72 6f 6e 74 2e 73 74 72 29 3b 0d 0a 09 7d  .front.str);...}
15d0: 0d 0a 0d 0a 09 41 53 54 20 70 61 72 73 65 4c 61  .....AST parseLa
15e0: 6d 62 64 61 41 66 74 65 72 4f 70 65 6e 50 61 72  mbdaAfterOpenPar
15f0: 65 6e 28 69 6d 6d 75 74 61 62 6c 65 20 4c 65 78  en(immutable Lex
1600: 50 6f 73 69 74 69 6f 6e 20 70 6f 73 29 0d 0a 09  Position pos)...
1610: 7b 0d 0a 09 09 73 74 72 69 6e 67 5b 5d 20 70 61  {....string[] pa
1620: 72 61 6d 73 3b 0d 0a 09 09 77 68 69 6c 65 28 20  rams;....while( 
1630: 21 74 72 79 45 61 74 28 22 29 22 29 20 29 0d 0a  !tryEat(")") )..
1640: 09 09 7b 0d 0a 09 09 09 70 61 72 61 6d 73 20 7e  ..{.....params ~
1650: 3d 20 65 61 74 49 64 28 22 66 6f 72 20 66 75 6e  = eatId("for fun
1660: 63 74 69 6f 6e 20 70 61 72 61 6d 65 74 65 72 22  ction parameter"
1670: 29 3b 0d 0a 09 09 09 69 66 28 20 21 74 72 79 45  );.....if( !tryE
1680: 61 74 28 22 2c 22 29 20 29 20 7b 0d 0a 09 09 09  at(",") ) {.....
1690: 09 65 61 74 28 22 29 22 2c 20 22 61 66 74 65 72  .eat(")", "after
16a0: 20 66 75 6e 63 74 69 6f 6e 20 70 61 72 61 6d 65   function parame
16b0: 74 65 72 73 22 29 3b 0d 0a 09 09 09 09 62 72 65  ters");......bre
16c0: 61 6b 3b 0d 0a 09 09 09 7d 0d 0a 09 09 7d 0d 0a  ak;.....}....}..
16d0: 09 09 65 61 74 28 22 7b 22 2c 20 22 61 66 74 65  ..eat("{", "afte
16e0: 72 20 66 75 6e 63 74 69 6f 6e 20 70 61 72 61 6d  r function param
16f0: 65 74 65 72 73 22 29 3b 0d 0a 09 09 61 75 74 6f  eters");....auto
1700: 20 66 75 6e 62 6f 64 79 20 3d 20 42 6f 64 79 28   funbody = Body(
1710: 29 3b 0d 0a 09 09 65 61 74 28 22 7d 22 2c 20 22  );....eat("}", "
1720: 61 66 74 65 72 20 66 75 6e 63 74 69 6f 6e 20 62  after function b
1730: 6f 64 79 22 29 3b 0d 0a 09 09 72 65 74 75 72 6e  ody");....return
1740: 20 6e 65 77 20 46 75 6e 4c 69 74 65 72 61 6c 28   new FunLiteral(
1750: 70 6f 73 2c 20 70 61 72 61 6d 73 2c 20 66 75 6e  pos, params, fun
1760: 62 6f 64 79 29 3b 0d 0a 09 7d 0d 0a 0d 0a 70 72  body);...}....pr
1770: 69 76 61 74 65 3a 0d 0a 09 4c 65 78 65 72 20 6c  ivate:...Lexer l
1780: 65 78 3b 0d 0a 09 74 68 69 73 28 4c 65 78 65 72  ex;...this(Lexer
1790: 20 6c 65 78 29 20 7b 20 74 68 69 73 2e 6c 65 78   lex) { this.lex
17a0: 20 3d 20 6c 65 78 3b 20 7d 0d 0a 0d 0a 09 76 6f   = lex; }.....vo
17b0: 69 64 20 65 61 74 28 73 74 72 69 6e 67 20 6b 77  id eat(string kw
17c0: 64 2c 20 6c 61 7a 79 20 73 74 72 69 6e 67 20 6d  d, lazy string m
17d0: 73 67 29 0d 0a 09 7b 0d 0a 09 09 69 66 28 20 21  sg)...{....if( !
17e0: 74 72 79 45 61 74 28 6b 77 64 29 20 29 0d 0a 09  tryEat(kwd) )...
17f0: 09 09 69 66 28 20 6c 65 78 2e 65 6d 70 74 79 20  ..if( lex.empty 
1800: 29 0d 0a 09 09 09 09 74 68 72 6f 77 20 67 65 6e  )......throw gen
1810: 65 78 21 55 6e 65 78 70 65 63 74 65 64 45 4f 46  ex!UnexpectedEOF
1820: 28 0d 0a 09 09 09 09 09 63 75 72 72 65 6e 74 50  (.......currentP
1830: 6f 73 69 74 69 6f 6e 28 29 2c 20 73 70 72 69 6e  osition(), sprin
1840: 74 66 21 22 25 73 20 69 73 20 65 78 70 65 63 74  tf!"%s is expect
1850: 65 64 20 66 6f 72 20 25 73 20 62 75 74 20 6e 6f  ed for %s but no
1860: 74 20 66 6f 75 6e 64 22 28 6b 77 64 2c 6d 73 67  t found"(kwd,msg
1870: 29 29 3b 0d 0a 09 09 09 65 6c 73 65 0d 0a 09 09  ));.....else....
1880: 09 09 74 68 72 6f 77 20 67 65 6e 65 78 21 50 61  ..throw genex!Pa
1890: 72 73 65 45 78 63 65 70 74 69 6f 6e 28 0d 0a 09  rseException(...
18a0: 09 09 09 09 63 75 72 72 65 6e 74 50 6f 73 69 74  ....currentPosit
18b0: 69 6f 6e 28 29 2c 20 73 70 72 69 6e 74 66 21 22  ion(), sprintf!"
18c0: 25 73 20 69 73 20 65 78 70 65 63 74 65 64 20 66  %s is expected f
18d0: 6f 72 20 25 73 20 62 75 74 20 6e 6f 74 20 66 6f  or %s but not fo
18e0: 75 6e 64 22 28 6b 77 64 2c 6d 73 67 29 29 3b 0d  und"(kwd,msg));.
18f0: 0a 09 7d 0d 0a 0d 0a 09 62 6f 6f 6c 20 74 72 79  ..}.....bool try
1900: 45 61 74 28 73 74 72 69 6e 67 20 6b 77 64 29 0d  Eat(string kwd).
1910: 0a 09 7b 0d 0a 09 09 69 66 28 20 6c 65 78 2e 65  ..{....if( lex.e
1920: 6d 70 74 79 20 7c 7c 20 6c 65 78 2e 66 72 6f 6e  mpty || lex.fron
1930: 74 2e 71 75 6f 74 65 64 20 7c 7c 20 6c 65 78 2e  t.quoted || lex.
1940: 66 72 6f 6e 74 2e 73 74 72 21 3d 6b 77 64 20 29  front.str!=kwd )
1950: 0d 0a 09 09 09 72 65 74 75 72 6e 20 66 61 6c 73  .....return fals
1960: 65 3b 0d 0a 09 09 6c 65 78 2e 70 6f 70 46 72 6f  e;....lex.popFro
1970: 6e 74 3b 0d 0a 09 09 72 65 74 75 72 6e 20 74 72  nt;....return tr
1980: 75 65 3b 0d 0a 09 7d 0d 0a 0d 0a 09 73 74 72 69  ue;...}.....stri
1990: 6e 67 20 65 61 74 49 64 28 6c 61 7a 79 20 73 74  ng eatId(lazy st
19a0: 72 69 6e 67 20 6d 73 67 2c 20 62 6f 6f 6c 20 61  ring msg, bool a
19b0: 6c 6c 6f 77 51 75 6f 74 65 64 3d 66 61 6c 73 65  llowQuoted=false
19c0: 29 0d 0a 09 7b 0d 0a 09 09 69 66 28 20 6c 65 78  )...{....if( lex
19d0: 2e 65 6d 70 74 79 20 29 0d 0a 09 09 09 74 68 72  .empty ).....thr
19e0: 6f 77 20 67 65 6e 65 78 21 55 6e 65 78 70 65 63  ow genex!Unexpec
19f0: 74 65 64 45 4f 46 28 63 75 72 72 65 6e 74 50 6f  tedEOF(currentPo
1a00: 73 69 74 69 6f 6e 28 29 2c 20 22 69 64 65 6e 74  sition(), "ident
1a10: 69 66 69 65 72 20 69 73 20 65 78 70 65 63 74 65  ifier is expecte
1a20: 64 20 62 75 74 20 6e 6f 74 20 66 6f 75 6e 64 20  d but not found 
1a30: 22 7e 6d 73 67 29 3b 0d 0a 09 09 69 66 28 20 21  "~msg);....if( !
1a40: 61 6c 6c 6f 77 51 75 6f 74 65 64 20 26 26 20 6c  allowQuoted && l
1a50: 65 78 2e 66 72 6f 6e 74 2e 71 75 6f 74 65 64 20  ex.front.quoted 
1a60: 29 0d 0a 09 09 09 74 68 72 6f 77 20 67 65 6e 65  ).....throw gene
1a70: 78 21 50 61 72 73 65 45 78 63 65 70 74 69 6f 6e  x!ParseException
1a80: 28 63 75 72 72 65 6e 74 50 6f 73 69 74 69 6f 6e  (currentPosition
1a90: 28 29 2c 20 22 69 64 65 6e 74 69 66 69 65 72 20  (), "identifier 
1aa0: 69 73 20 65 78 70 65 63 74 65 64 20 62 75 74 20  is expected but 
1ab0: 6e 6f 74 20 66 6f 75 6e 64 20 22 7e 6d 73 67 29  not found "~msg)
1ac0: 3b 0d 0a 09 09 73 63 6f 70 65 28 65 78 69 74 29  ;....scope(exit)
1ad0: 20 6c 65 78 2e 70 6f 70 46 72 6f 6e 74 3b 0d 0a   lex.popFront;..
1ae0: 09 09 72 65 74 75 72 6e 20 6c 65 78 2e 66 72 6f  ..return lex.fro
1af0: 6e 74 2e 73 74 72 3b 0d 0a 09 7d 0d 0a 0d 0a 09  nt.str;...}.....
1b00: 62 6f 6f 6c 20 69 73 4e 75 6d 62 65 72 28 73 74  bool isNumber(st
1b10: 72 69 6e 67 20 73 29 0d 0a 09 7b 0d 0a 09 09 72  ring s)...{....r
1b20: 65 74 75 72 6e 20 66 69 6e 64 21 28 60 61 3c 27  eturn find!(`a<'
1b30: 30 27 7c 7c 27 39 27 3c 61 60 29 28 73 29 2e 65  0'||'9'<a`)(s).e
1b40: 6d 70 74 79 3b 0d 0a 09 7d 0d 0a 0d 0a 09 41 53  mpty;...}.....AS
1b50: 54 20 64 6f 4e 6f 74 68 69 6e 67 45 78 70 72 65  T doNothingExpre
1b60: 73 73 69 6f 6e 28 29 0d 0a 09 7b 0d 0a 09 09 72  ssion()...{....r
1b70: 65 74 75 72 6e 20 6e 65 77 20 49 6e 74 4c 69 74  eturn new IntLit
1b80: 65 72 61 6c 28 63 75 72 72 65 6e 74 50 6f 73 69  eral(currentPosi
1b90: 74 69 6f 6e 28 29 2c 20 42 69 67 49 6e 74 28 31  tion(), BigInt(1
1ba0: 37 38 29 29 3b 0d 0a 09 7d 0d 0a 0d 0a 09 69 6d  78));...}.....im
1bb0: 6d 75 74 61 62 6c 65 28 4c 65 78 50 6f 73 69 74  mutable(LexPosit
1bc0: 69 6f 6e 29 20 63 75 72 72 65 6e 74 50 6f 73 69  ion) currentPosi
1bd0: 74 69 6f 6e 28 29 0d 0a 09 7b 0d 0a 09 09 72 65  tion()...{....re
1be0: 74 75 72 6e 20 6c 65 78 2e 65 6d 70 74 79 20 3f  turn lex.empty ?
1bf0: 20 6e 75 6c 6c 20 3a 20 6c 65 78 2e 66 72 6f 6e   null : lex.fron
1c00: 74 2e 70 6f 73 3b 0d 0a 09 7d 0d 0a 7d 0d 0a 0d  t.pos;...}..}...
1c10: 0a 75 6e 69 74 74 65 73 74 0d 0a 7b 0d 0a 09 6d  .unittest..{...m
1c20: 69 78 69 6e 20 45 61 73 79 41 53 54 3b 0d 0a 0d  ixin EasyAST;...
1c30: 0a 09 61 73 73 65 72 74 5f 65 71 28 70 61 72 73  ..assert_eq(pars
1c40: 65 53 74 72 69 6e 67 28 60 31 32 33 60 29 2c 20  eString(`123`), 
1c50: 69 6e 74 6c 28 31 32 33 29 29 3b 0d 0a 09 61 73  intl(123));...as
1c60: 73 65 72 74 5f 65 71 28 70 61 72 73 65 53 74 72  sert_eq(parseStr
1c70: 69 6e 67 28 60 22 66 6f 6f 22 60 29 2c 20 73 74  ing(`"foo"`), st
1c80: 72 6c 28 22 66 6f 6f 22 29 29 3b 0d 0a 09 61 73  rl("foo"));...as
1c90: 73 65 72 74 5f 65 71 28 70 61 72 73 65 53 74 72  sert_eq(parseStr
1ca0: 69 6e 67 28 60 66 75 6e 28 29 7b 31 7d 60 29 2c  ing(`fun(){1}`),
1cb0: 20 66 75 6e 28 5b 5d 2c 69 6e 74 6c 28 31 29 29   fun([],intl(1))
1cc0: 29 3b 0d 0a 09 61 73 73 65 72 74 5f 65 71 28 70  );...assert_eq(p
1cd0: 61 72 73 65 53 74 72 69 6e 67 28 60 66 75 6e 28  arseString(`fun(
1ce0: 78 29 7b 31 7d 60 29 2c 20 66 75 6e 28 5b 22 78  x){1}`), fun(["x
1cf0: 22 5d 2c 69 6e 74 6c 28 31 29 29 29 3b 0d 0a 09  "],intl(1)));...
1d00: 61 73 73 65 72 74 5f 65 71 28 70 61 72 73 65 53  assert_eq(parseS
1d10: 74 72 69 6e 67 28 22 5c 75 30 33 42 42 28 29 7b  tring("\u03BB(){
1d20: 31 7d 22 29 2c 20 66 75 6e 28 5b 5d 2c 69 6e 74  1}"), fun([],int
1d30: 6c 28 31 29 29 29 3b 0d 0a 09 61 73 73 65 72 74  l(1)));...assert
1d40: 5f 65 71 28 70 61 72 73 65 53 74 72 69 6e 67 28  _eq(parseString(
1d50: 22 5c 75 30 33 42 42 28 78 29 7b 31 7d 22 29 2c  "\u03BB(x){1}"),
1d60: 20 66 75 6e 28 5b 22 78 22 5d 2c 69 6e 74 6c 28   fun(["x"],intl(
1d70: 31 29 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f 65  1)));...assert_e
1d80: 71 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 31  q(parseString(`1
1d90: 3b 32 60 29 2c 20 6c 65 74 28 22 5f 22 2c 22 22  ;2`), let("_",""
1da0: 2c 69 6e 74 6c 28 31 29 2c 69 6e 74 6c 28 32 29  ,intl(1),intl(2)
1db0: 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f 65 71 28  ));...assert_eq(
1dc0: 70 61 72 73 65 53 74 72 69 6e 67 28 60 31 3b 32  parseString(`1;2
1dd0: 3b 60 29 2c 20 6c 65 74 28 22 5f 22 2c 22 22 2c  ;`), let("_","",
1de0: 69 6e 74 6c 28 31 29 2c 69 6e 74 6c 28 32 29 29  intl(1),intl(2))
1df0: 29 3b 0d 0a 09 61 73 73 65 72 74 5f 65 71 28 70  );...assert_eq(p
1e00: 61 72 73 65 53 74 72 69 6e 67 28 60 6c 65 74 20  arseString(`let 
1e10: 78 3d 31 3b 32 60 29 2c 20 6c 65 74 28 22 78 22  x=1;2`), let("x"
1e20: 2c 22 22 2c 69 6e 74 6c 28 31 29 2c 69 6e 74 6c  ,"",intl(1),intl
1e30: 28 32 29 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f  (2)));...assert_
1e40: 65 71 28 70 61 72 73 65 53 74 72 69 6e 67 28 60  eq(parseString(`
1e50: 76 61 72 20 78 3d 31 3b 32 3b 60 29 2c 20 6c 65  var x=1;2;`), le
1e60: 74 28 22 78 22 2c 22 22 2c 69 6e 74 6c 28 31 29  t("x","",intl(1)
1e70: 2c 69 6e 74 6c 28 32 29 29 29 3b 0d 0a 09 61 73  ,intl(2)));...as
1e80: 73 65 72 74 5f 65 71 28 70 61 72 73 65 53 74 72  sert_eq(parseStr
1e90: 69 6e 67 28 60 64 65 66 20 78 3d 31 60 29 2c 20  ing(`def x=1`), 
1ea0: 6c 65 74 28 22 78 22 2c 22 22 2c 69 6e 74 6c 28  let("x","",intl(
1eb0: 31 29 2c 76 61 72 28 22 78 22 29 29 29 3b 0d 0a  1),var("x")));..
1ec0: 09 61 73 73 65 72 74 5f 65 71 28 70 61 72 73 65  .assert_eq(parse
1ed0: 53 74 72 69 6e 67 28 60 40 76 61 6c 20 78 3d 31  String(`@val x=1
1ee0: 3b 60 29 2c 20 6c 65 74 28 22 78 22 2c 22 40 76  ;`), let("x","@v
1ef0: 61 6c 22 2c 69 6e 74 6c 28 31 29 2c 76 61 72 28  al",intl(1),var(
1f00: 22 78 22 29 29 29 3b 0d 0a 09 61 73 73 65 72 74  "x")));...assert
1f10: 5f 65 71 28 70 61 72 73 65 53 74 72 69 6e 67 28  _eq(parseString(
1f20: 60 40 74 79 70 20 78 3d 22 23 69 6e 74 22 3b 60  `@typ x="#int";`
1f30: 29 2c 20 6c 65 74 28 22 78 22 2c 22 40 74 79 70  ), let("x","@typ
1f40: 22 2c 73 74 72 6c 28 22 23 69 6e 74 22 29 2c 76  ",strl("#int"),v
1f50: 61 72 28 22 78 22 29 29 29 3b 0d 0a 09 61 73 73  ar("x")));...ass
1f60: 65 72 74 5f 65 71 28 70 61 72 73 65 53 74 72 69  ert_eq(parseStri
1f70: 6e 67 28 60 66 28 31 2c 32 29 60 29 2c 20 63 61  ng(`f(1,2)`), ca
1f80: 6c 6c 28 76 61 72 28 22 66 22 29 2c 69 6e 74 6c  ll(var("f"),intl
1f90: 28 31 29 2c 69 6e 74 6c 28 32 29 29 29 3b 0d 0a  (1),intl(2)));..
1fa0: 09 61 73 73 65 72 74 5f 65 71 28 70 61 72 73 65  .assert_eq(parse
1fb0: 53 74 72 69 6e 67 28 60 69 66 28 31 29 7b 32 7d  String(`if(1){2}
1fc0: 60 29 2c 20 63 61 6c 6c 28 76 61 72 28 22 69 66  `), call(var("if
1fd0: 22 29 2c 69 6e 74 6c 28 31 29 2c 66 75 6e 28 5b  "),intl(1),fun([
1fe0: 5d 2c 69 6e 74 6c 28 32 29 29 2c 66 75 6e 28 5b  ],intl(2)),fun([
1ff0: 5d 2c 69 6e 74 6c 28 31 37 38 29 29 29 29 3b 0d  ],intl(178))));.
2000: 0a 09 61 73 73 65 72 74 5f 65 71 28 70 61 72 73  ..assert_eq(pars
2010: 65 53 74 72 69 6e 67 28 60 69 66 28 31 29 7b 32  eString(`if(1){2
2020: 7d 65 6c 73 65 7b 33 7d 60 29 2c 20 63 61 6c 6c  }else{3}`), call
2030: 28 76 61 72 28 22 69 66 22 29 2c 69 6e 74 6c 28  (var("if"),intl(
2040: 31 29 2c 66 75 6e 28 5b 5d 2c 69 6e 74 6c 28 32  1),fun([],intl(2
2050: 29 29 2c 66 75 6e 28 5b 5d 2c 69 6e 74 6c 28 33  )),fun([],intl(3
2060: 29 29 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f 65  ))));...assert_e
2070: 71 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 69  q(parseString(`i
2080: 66 28 31 29 7b 7d 65 6c 73 65 7b 33 7d 28 29 28  f(1){}else{3}()(
2090: 29 60 29 2c 0d 0a 09 09 63 61 6c 6c 28 63 61 6c  )`),....call(cal
20a0: 6c 28 63 61 6c 6c 28 76 61 72 28 22 69 66 22 29  l(call(var("if")
20b0: 2c 69 6e 74 6c 28 31 29 2c 66 75 6e 28 5b 5d 2c  ,intl(1),fun([],
20c0: 69 6e 74 6c 28 31 37 38 29 29 2c 66 75 6e 28 5b  intl(178)),fun([
20d0: 5d 2c 69 6e 74 6c 28 33 29 29 29 29 29 29 3b 0d  ],intl(3))))));.
20e0: 0a 09 61 73 73 65 72 74 5f 65 71 28 70 61 72 73  ..assert_eq(pars
20f0: 65 53 74 72 69 6e 67 28 60 31 2b 32 2a 33 60 29  eString(`1+2*3`)
2100: 2c 20 63 61 6c 6c 28 76 61 72 28 22 2b 22 29 2c  , call(var("+"),
2110: 69 6e 74 6c 28 31 29 2c 63 61 6c 6c 28 76 61 72  intl(1),call(var
2120: 28 22 2a 22 29 2c 69 6e 74 6c 28 32 29 2c 69 6e  ("*"),intl(2),in
2130: 74 6c 28 33 29 29 29 29 3b 0d 0a 09 61 73 73 65  tl(3))));...asse
2140: 72 74 5f 65 71 28 70 61 72 73 65 53 74 72 69 6e  rt_eq(parseStrin
2150: 67 28 60 28 31 2b 32 29 2a 33 60 29 2c 20 63 61  g(`(1+2)*3`), ca
2160: 6c 6c 28 76 61 72 28 22 2a 22 29 2c 63 61 6c 6c  ll(var("*"),call
2170: 28 76 61 72 28 22 2b 22 29 2c 69 6e 74 6c 28 31  (var("+"),intl(1
2180: 29 2c 69 6e 74 6c 28 32 29 29 2c 69 6e 74 6c 28  ),intl(2)),intl(
2190: 33 29 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f 65  3)));...assert_e
21a0: 71 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 31  q(parseString(`1
21b0: 2a 28 32 2b 33 29 60 29 2c 20 63 61 6c 6c 28 76  *(2+3)`), call(v
21c0: 61 72 28 22 2a 22 29 2c 69 6e 74 6c 28 31 29 2c  ar("*"),intl(1),
21d0: 63 61 6c 6c 28 76 61 72 28 22 2b 22 29 2c 69 6e  call(var("+"),in
21e0: 74 6c 28 32 29 2c 69 6e 74 6c 28 33 29 29 29 29  tl(2),intl(3))))
21f0: 3b 0d 0a 09 61 73 73 65 72 74 5f 65 71 28 70 61  ;...assert_eq(pa
2200: 72 73 65 53 74 72 69 6e 67 28 60 31 2a 32 2b 33  rseString(`1*2+3
2210: 60 29 2c 20 63 61 6c 6c 28 76 61 72 28 22 2b 22  `), call(var("+"
2220: 29 2c 63 61 6c 6c 28 76 61 72 28 22 2a 22 29 2c  ),call(var("*"),
2230: 69 6e 74 6c 28 31 29 2c 69 6e 74 6c 28 32 29 29  intl(1),intl(2))
2240: 2c 69 6e 74 6c 28 33 29 29 29 3b 0d 0a 09 61 73  ,intl(3)));...as
2250: 73 65 72 74 5f 65 71 28 70 61 72 73 65 53 74 72  sert_eq(parseStr
2260: 69 6e 67 28 60 40 78 28 31 29 60 29 2c 20 6c 61  ing(`@x(1)`), la
2270: 79 28 22 40 78 22 2c 20 69 6e 74 6c 28 31 29 29  y("@x", intl(1))
2280: 29 3b 0d 0a 0d 0a 09 61 73 73 65 72 74 5f 65 71  );.....assert_eq
2290: 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 0d 0a  (parseString(`..
22a0: 09 09 6c 65 74 20 78 20 3d 20 31 30 30 3b 20 23  ..let x = 100; #
22b0: 63 6f 6d 6d 65 6e 74 0d 0a 09 09 6c 65 74 20 79  comment....let y
22c0: 20 3d 20 32 30 30 3b 20 23 63 6f 6d 6d 65 6e 74   = 200; #comment
22d0: 21 21 21 21 21 0d 0a 09 09 09 78 2b 79 0d 0a 09  !!!!!.....x+y...
22e0: 60 29 2c 0d 0a 09 09 6c 65 74 28 22 78 22 2c 20  `),....let("x", 
22f0: 22 22 2c 20 69 6e 74 6c 28 31 30 30 29 2c 20 6c  "", intl(100), l
2300: 65 74 28 22 79 22 2c 20 22 22 2c 20 69 6e 74 6c  et("y", "", intl
2310: 28 32 30 30 29 2c 20 63 61 6c 6c 28 76 61 72 28  (200), call(var(
2320: 22 2b 22 29 2c 20 76 61 72 28 22 78 22 29 2c 20  "+"), var("x"), 
2330: 76 61 72 28 22 79 22 29 29 29 29 0d 0a 09 29 3b  var("y"))))...);
2340: 0d 0a 0d 0a 09 61 73 73 65 72 74 5f 65 71 28 70  .....assert_eq(p
2350: 61 72 73 65 53 74 72 69 6e 67 28 60 0d 0a 09 09  arseString(`....
2360: 76 61 72 20 66 61 63 20 3d 20 66 75 6e 28 78 29  var fac = fun(x)
2370: 7b 20 69 66 28 78 20 3c 3d 20 31 29 20 7b 31 7d  { if(x <= 1) {1}
2380: 20 65 6c 73 65 20 7b 78 2a 66 61 63 28 78 2d 31   else {x*fac(x-1
2390: 29 7d 20 7d 3b 0d 0a 09 09 66 61 63 28 31 30 29  )} };....fac(10)
23a0: 0d 0a 09 60 29 2c 0d 0a 09 09 6c 65 74 28 22 66  ...`),....let("f
23b0: 61 63 22 2c 20 22 22 2c 20 66 75 6e 28 5b 22 78  ac", "", fun(["x
23c0: 22 5d 2c 0d 0a 09 09 09 63 61 6c 6c 28 76 61 72  "],.....call(var
23d0: 28 22 69 66 22 29 2c 0d 0a 09 09 09 09 63 61 6c  ("if"),......cal
23e0: 6c 28 76 61 72 28 22 3c 3d 22 29 2c 20 76 61 72  l(var("<="), var
23f0: 28 22 78 22 29 2c 20 69 6e 74 6c 28 31 29 29 2c  ("x"), intl(1)),
2400: 0d 0a 09 09 09 09 66 75 6e 28 5b 5d 2c 20 69 6e  ......fun([], in
2410: 74 6c 28 31 29 29 2c 0d 0a 09 09 09 09 66 75 6e  tl(1)),......fun
2420: 28 5b 5d 2c 20 63 61 6c 6c 28 76 61 72 28 22 2a  ([], call(var("*
2430: 22 29 2c 20 76 61 72 28 22 78 22 29 2c 20 63 61  "), var("x"), ca
2440: 6c 6c 28 76 61 72 28 22 66 61 63 22 29 2c 63 61  ll(var("fac"),ca
2450: 6c 6c 28 76 61 72 28 22 2d 22 29 2c 76 61 72 28  ll(var("-"),var(
2460: 22 78 22 29 2c 69 6e 74 6c 28 31 29 29 29 29 29  "x"),intl(1)))))
2470: 0d 0a 09 09 09 29 29 2c 0d 0a 09 09 09 63 61 6c  .....)),.....cal
2480: 6c 28 76 61 72 28 22 66 61 63 22 29 2c 69 6e 74  l(var("fac"),int
2490: 6c 28 31 30 29 29 0d 0a 09 09 29 0d 0a 09 29 3b  l(10))....)...);
24a0: 0d 0a 7d 0d 0a 0d 0a 75 6e 69 74 74 65 73 74 0d  ..}....unittest.
24b0: 0a 7b 0d 0a 09 61 73 73 65 72 74 5f 74 68 72 6f  .{...assert_thro
24c0: 77 21 55 6e 65 78 70 65 63 74 65 64 45 4f 46 28  w!UnexpectedEOF(
24d0: 70 61 72 73 65 53 74 72 69 6e 67 28 60 31 2b 60  parseString(`1+`
24e0: 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f 74 68 72  ));...assert_thr
24f0: 6f 77 21 50 61 72 73 65 45 78 63 65 70 74 69 6f  ow!ParseExceptio
2500: 6e 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 31  n(parseString(`1
2510: 2b 32 7d 60 29 29 3b 0d 0a 09 61 73 73 65 72 74  +2}`));...assert
2520: 5f 74 68 72 6f 77 21 55 6e 65 78 70 65 63 74 65  _throw!Unexpecte
2530: 64 45 4f 46 28 70 61 72 73 65 53 74 72 69 6e 67  dEOF(parseString
2540: 28 60 6c 65 74 20 22 78 22 60 29 29 3b 0d 0a 09  (`let "x"`));...
2550: 61 73 73 65 72 74 5f 74 68 72 6f 77 21 55 6e 65  assert_throw!Une
2560: 78 70 65 63 74 65 64 45 4f 46 28 70 61 72 73 65  xpectedEOF(parse
2570: 53 74 72 69 6e 67 28 60 76 61 72 60 29 29 3b 0d  String(`var`));.
2580: 0a 09 61 73 73 65 72 74 5f 74 68 72 6f 77 21 50  ..assert_throw!P
2590: 61 72 73 65 45 78 63 65 70 74 69 6f 6e 28 70 61  arseException(pa
25a0: 72 73 65 53 74 72 69 6e 67 28 60 40 76 61 6c 20  rseString(`@val 
25b0: 78 20 3d 3d 60 29 29 3b 0d 0a 09 61 73 73 65 72  x ==`));...asser
25c0: 74 5f 74 68 72 6f 77 21 50 61 72 73 65 45 78 63  t_throw!ParseExc
25d0: 65 70 74 69 6f 6e 28 70 61 72 73 65 53 74 72 69  eption(parseStri
25e0: 6e 67 28 60 69 66 28 29 7b 31 7d 60 29 29 3b 0d  ng(`if(){1}`));.
25f0: 0a 09 61 73 73 65 72 74 5f 74 68 72 6f 77 21 55  ..assert_throw!U
2600: 6e 65 78 70 65 63 74 65 64 45 4f 46 28 70 61 72  nexpectedEOF(par
2610: 73 65 53 74 72 69 6e 67 28 60 66 28 60 29 29 3b  seString(`f(`));
2620: 0d 0a 7d 0d 0a 0d 0a 75 6e 69 74 74 65 73 74 0d  ..}....unittest.
2630: 0a 7b 0d 0a 09 6d 69 78 69 6e 20 45 61 73 79 41  .{...mixin EasyA
2640: 53 54 3b 0d 0a 09 61 73 73 65 72 74 5f 65 71 28  ST;...assert_eq(
2650: 70 61 72 73 65 53 74 72 69 6e 67 28 60 64 65 66  parseString(`def
2660: 20 66 6f 6f 28 78 29 20 7b 20 78 2b 31 20 7d 3b   foo(x) { x+1 };
2670: 20 66 6f 6f 60 29 2c 0d 0a 09 09 6c 65 74 28 22   foo`),....let("
2680: 66 6f 6f 22 2c 20 22 22 2c 0d 0a 09 09 09 66 75  foo", "",.....fu
2690: 6e 28 5b 22 78 22 5d 2c 20 63 61 6c 6c 28 76 61  n(["x"], call(va
26a0: 72 28 22 2b 22 29 2c 20 76 61 72 28 22 78 22 29  r("+"), var("x")
26b0: 2c 20 69 6e 74 6c 28 31 29 29 29 2c 0d 0a 09 09  , intl(1))),....
26c0: 09 76 61 72 28 22 66 6f 6f 22 29 29 0d 0a 09 29  .var("foo"))...)
26d0: 3b 0d 0a 7d 0d 0a                                ;..}..