Hex Artifact Content
Not logged in

Artifact d3a7b70fa2f3b803d6b6fd53a4b8e28b379c7992:


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 50 61 72 61 6d 65 74 65 72 5b 5d  {....Parameter[]
1620: 20 70 61 72 61 6d 73 3b 0d 0a 09 09 77 68 69 6c   params;....whil
1630: 65 28 20 21 74 72 79 45 61 74 28 22 29 22 29 20  e( !tryEat(")") 
1640: 29 0d 0a 09 09 7b 0d 0a 09 09 09 70 61 72 61 6d  )....{.....param
1650: 73 20 7e 3d 20 6e 65 77 20 50 61 72 61 6d 65 74  s ~= new Paramet
1660: 65 72 28 65 61 74 49 64 28 22 66 6f 72 20 66 75  er(eatId("for fu
1670: 6e 63 74 69 6f 6e 20 70 61 72 61 6d 65 74 65 72  nction parameter
1680: 22 29 2c 20 5b 5d 29 3b 0d 0a 09 09 09 69 66 28  "), []);.....if(
1690: 20 21 74 72 79 45 61 74 28 22 2c 22 29 20 29 20   !tryEat(",") ) 
16a0: 7b 0d 0a 09 09 09 09 65 61 74 28 22 29 22 2c 20  {......eat(")", 
16b0: 22 61 66 74 65 72 20 66 75 6e 63 74 69 6f 6e 20  "after function 
16c0: 70 61 72 61 6d 65 74 65 72 73 22 29 3b 0d 0a 09  parameters");...
16d0: 09 09 09 62 72 65 61 6b 3b 0d 0a 09 09 09 7d 0d  ...break;.....}.
16e0: 0a 09 09 7d 0d 0a 09 09 65 61 74 28 22 7b 22 2c  ...}....eat("{",
16f0: 20 22 61 66 74 65 72 20 66 75 6e 63 74 69 6f 6e   "after function
1700: 20 70 61 72 61 6d 65 74 65 72 73 22 29 3b 0d 0a   parameters");..
1710: 09 09 61 75 74 6f 20 66 75 6e 62 6f 64 79 20 3d  ..auto funbody =
1720: 20 42 6f 64 79 28 29 3b 0d 0a 09 09 65 61 74 28   Body();....eat(
1730: 22 7d 22 2c 20 22 61 66 74 65 72 20 66 75 6e 63  "}", "after func
1740: 74 69 6f 6e 20 62 6f 64 79 22 29 3b 0d 0a 09 09  tion body");....
1750: 72 65 74 75 72 6e 20 6e 65 77 20 46 75 6e 4c 69  return new FunLi
1760: 74 65 72 61 6c 28 70 6f 73 2c 20 70 61 72 61 6d  teral(pos, param
1770: 73 2c 20 66 75 6e 62 6f 64 79 29 3b 0d 0a 09 7d  s, funbody);...}
1780: 0d 0a 0d 0a 70 72 69 76 61 74 65 3a 0d 0a 09 4c  ....private:...L
1790: 65 78 65 72 20 6c 65 78 3b 0d 0a 09 74 68 69 73  exer lex;...this
17a0: 28 4c 65 78 65 72 20 6c 65 78 29 20 7b 20 74 68  (Lexer lex) { th
17b0: 69 73 2e 6c 65 78 20 3d 20 6c 65 78 3b 20 7d 0d  is.lex = lex; }.
17c0: 0a 0d 0a 09 76 6f 69 64 20 65 61 74 28 73 74 72  ....void eat(str
17d0: 69 6e 67 20 6b 77 64 2c 20 6c 61 7a 79 20 73 74  ing kwd, lazy st
17e0: 72 69 6e 67 20 6d 73 67 29 0d 0a 09 7b 0d 0a 09  ring msg)...{...
17f0: 09 69 66 28 20 21 74 72 79 45 61 74 28 6b 77 64  .if( !tryEat(kwd
1800: 29 20 29 0d 0a 09 09 09 69 66 28 20 6c 65 78 2e  ) ).....if( lex.
1810: 65 6d 70 74 79 20 29 0d 0a 09 09 09 09 74 68 72  empty )......thr
1820: 6f 77 20 67 65 6e 65 78 21 55 6e 65 78 70 65 63  ow genex!Unexpec
1830: 74 65 64 45 4f 46 28 0d 0a 09 09 09 09 09 63 75  tedEOF(.......cu
1840: 72 72 65 6e 74 50 6f 73 69 74 69 6f 6e 28 29 2c  rrentPosition(),
1850: 20 73 70 72 69 6e 74 66 21 22 25 73 20 69 73 20   sprintf!"%s is 
1860: 65 78 70 65 63 74 65 64 20 25 73 20 62 75 74 20  expected %s but 
1870: 6e 6f 74 20 66 6f 75 6e 64 22 28 6b 77 64 2c 6d  not found"(kwd,m
1880: 73 67 29 29 3b 0d 0a 09 09 09 65 6c 73 65 0d 0a  sg));.....else..
1890: 09 09 09 09 74 68 72 6f 77 20 67 65 6e 65 78 21  ....throw genex!
18a0: 50 61 72 73 65 45 78 63 65 70 74 69 6f 6e 28 0d  ParseException(.
18b0: 0a 09 09 09 09 09 63 75 72 72 65 6e 74 50 6f 73  ......currentPos
18c0: 69 74 69 6f 6e 28 29 2c 20 73 70 72 69 6e 74 66  ition(), sprintf
18d0: 21 22 25 73 20 69 73 20 65 78 70 65 63 74 65 64  !"%s is expected
18e0: 20 66 6f 72 20 25 73 20 62 75 74 20 6e 6f 74 20   for %s but not 
18f0: 66 6f 75 6e 64 22 28 6b 77 64 2c 6d 73 67 29 29  found"(kwd,msg))
1900: 3b 0d 0a 09 7d 0d 0a 0d 0a 09 62 6f 6f 6c 20 74  ;...}.....bool t
1910: 72 79 45 61 74 28 73 74 72 69 6e 67 20 6b 77 64  ryEat(string kwd
1920: 29 0d 0a 09 7b 0d 0a 09 09 69 66 28 20 6c 65 78  )...{....if( lex
1930: 2e 65 6d 70 74 79 20 7c 7c 20 6c 65 78 2e 66 72  .empty || lex.fr
1940: 6f 6e 74 2e 71 75 6f 74 65 64 20 7c 7c 20 6c 65  ont.quoted || le
1950: 78 2e 66 72 6f 6e 74 2e 73 74 72 21 3d 6b 77 64  x.front.str!=kwd
1960: 20 29 0d 0a 09 09 09 72 65 74 75 72 6e 20 66 61   ).....return fa
1970: 6c 73 65 3b 0d 0a 09 09 6c 65 78 2e 70 6f 70 46  lse;....lex.popF
1980: 72 6f 6e 74 3b 0d 0a 09 09 72 65 74 75 72 6e 20  ront;....return 
1990: 74 72 75 65 3b 0d 0a 09 7d 0d 0a 0d 0a 09 73 74  true;...}.....st
19a0: 72 69 6e 67 20 65 61 74 49 64 28 6c 61 7a 79 20  ring eatId(lazy 
19b0: 73 74 72 69 6e 67 20 6d 73 67 2c 20 62 6f 6f 6c  string msg, bool
19c0: 20 61 6c 6c 6f 77 51 75 6f 74 65 64 3d 66 61 6c   allowQuoted=fal
19d0: 73 65 29 0d 0a 09 7b 0d 0a 09 09 69 66 28 20 6c  se)...{....if( l
19e0: 65 78 2e 65 6d 70 74 79 20 29 0d 0a 09 09 09 74  ex.empty ).....t
19f0: 68 72 6f 77 20 67 65 6e 65 78 21 55 6e 65 78 70  hrow genex!Unexp
1a00: 65 63 74 65 64 45 4f 46 28 63 75 72 72 65 6e 74  ectedEOF(current
1a10: 50 6f 73 69 74 69 6f 6e 28 29 2c 20 22 69 64 65  Position(), "ide
1a20: 6e 74 69 66 69 65 72 20 69 73 20 65 78 70 65 63  ntifier is expec
1a30: 74 65 64 20 62 75 74 20 6e 6f 74 20 66 6f 75 6e  ted but not foun
1a40: 64 20 22 7e 6d 73 67 29 3b 0d 0a 09 09 69 66 28  d "~msg);....if(
1a50: 20 21 61 6c 6c 6f 77 51 75 6f 74 65 64 20 26 26   !allowQuoted &&
1a60: 20 6c 65 78 2e 66 72 6f 6e 74 2e 71 75 6f 74 65   lex.front.quote
1a70: 64 20 29 0d 0a 09 09 09 74 68 72 6f 77 20 67 65  d ).....throw ge
1a80: 6e 65 78 21 50 61 72 73 65 45 78 63 65 70 74 69  nex!ParseExcepti
1a90: 6f 6e 28 63 75 72 72 65 6e 74 50 6f 73 69 74 69  on(currentPositi
1aa0: 6f 6e 28 29 2c 20 22 69 64 65 6e 74 69 66 69 65  on(), "identifie
1ab0: 72 20 69 73 20 65 78 70 65 63 74 65 64 20 62 75  r is expected bu
1ac0: 74 20 6e 6f 74 20 66 6f 75 6e 64 20 22 7e 6d 73  t not found "~ms
1ad0: 67 29 3b 0d 0a 09 09 73 63 6f 70 65 28 65 78 69  g);....scope(exi
1ae0: 74 29 20 6c 65 78 2e 70 6f 70 46 72 6f 6e 74 3b  t) lex.popFront;
1af0: 0d 0a 09 09 72 65 74 75 72 6e 20 6c 65 78 2e 66  ....return lex.f
1b00: 72 6f 6e 74 2e 73 74 72 3b 0d 0a 09 7d 0d 0a 0d  ront.str;...}...
1b10: 0a 09 62 6f 6f 6c 20 69 73 4e 75 6d 62 65 72 28  ..bool isNumber(
1b20: 73 74 72 69 6e 67 20 73 29 0d 0a 09 7b 0d 0a 09  string s)...{...
1b30: 09 72 65 74 75 72 6e 20 66 69 6e 64 21 28 60 61  .return find!(`a
1b40: 3c 27 30 27 7c 7c 27 39 27 3c 61 60 29 28 73 29  <'0'||'9'<a`)(s)
1b50: 2e 65 6d 70 74 79 3b 0d 0a 09 7d 0d 0a 0d 0a 09  .empty;...}.....
1b60: 41 53 54 20 64 6f 4e 6f 74 68 69 6e 67 45 78 70  AST doNothingExp
1b70: 72 65 73 73 69 6f 6e 28 29 0d 0a 09 7b 0d 0a 09  ression()...{...
1b80: 09 72 65 74 75 72 6e 20 6e 65 77 20 49 6e 74 4c  .return new IntL
1b90: 69 74 65 72 61 6c 28 63 75 72 72 65 6e 74 50 6f  iteral(currentPo
1ba0: 73 69 74 69 6f 6e 28 29 2c 20 42 69 67 49 6e 74  sition(), BigInt
1bb0: 28 31 37 38 29 29 3b 0d 0a 09 7d 0d 0a 0d 0a 09  (178));...}.....
1bc0: 69 6d 6d 75 74 61 62 6c 65 28 4c 65 78 50 6f 73  immutable(LexPos
1bd0: 69 74 69 6f 6e 29 20 63 75 72 72 65 6e 74 50 6f  ition) currentPo
1be0: 73 69 74 69 6f 6e 28 29 0d 0a 09 7b 0d 0a 09 09  sition()...{....
1bf0: 72 65 74 75 72 6e 20 6c 65 78 2e 65 6d 70 74 79  return lex.empty
1c00: 20 3f 20 6e 75 6c 6c 20 3a 20 6c 65 78 2e 66 72   ? null : lex.fr
1c10: 6f 6e 74 2e 70 6f 73 3b 0d 0a 09 7d 0d 0a 7d 0d  ont.pos;...}..}.
1c20: 0a 0d 0a 75 6e 69 74 74 65 73 74 0d 0a 7b 0d 0a  ...unittest..{..
1c30: 09 6d 69 78 69 6e 20 45 61 73 79 41 53 54 3b 0d  .mixin EasyAST;.
1c40: 0a 0d 0a 09 61 73 73 65 72 74 5f 65 71 28 70 61  ....assert_eq(pa
1c50: 72 73 65 53 74 72 69 6e 67 28 60 31 32 33 60 29  rseString(`123`)
1c60: 2c 20 69 6e 74 6c 28 31 32 33 29 29 3b 0d 0a 09  , intl(123));...
1c70: 61 73 73 65 72 74 5f 65 71 28 70 61 72 73 65 53  assert_eq(parseS
1c80: 74 72 69 6e 67 28 60 22 66 6f 6f 22 60 29 2c 20  tring(`"foo"`), 
1c90: 73 74 72 6c 28 22 66 6f 6f 22 29 29 3b 0d 0a 09  strl("foo"));...
1ca0: 61 73 73 65 72 74 5f 65 71 28 70 61 72 73 65 53  assert_eq(parseS
1cb0: 74 72 69 6e 67 28 60 66 75 6e 28 29 7b 31 7d 60  tring(`fun(){1}`
1cc0: 29 2c 20 66 75 6e 28 5b 5d 2c 69 6e 74 6c 28 31  ), fun([],intl(1
1cd0: 29 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f 65 71  )));...assert_eq
1ce0: 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 66 75  (parseString(`fu
1cf0: 6e 28 78 29 7b 31 7d 60 29 2c 20 66 75 6e 28 5b  n(x){1}`), fun([
1d00: 22 78 22 5d 2c 69 6e 74 6c 28 31 29 29 29 3b 0d  "x"],intl(1)));.
1d10: 0a 09 61 73 73 65 72 74 5f 65 71 28 70 61 72 73  ..assert_eq(pars
1d20: 65 53 74 72 69 6e 67 28 22 5c 75 30 33 42 42 28  eString("\u03BB(
1d30: 29 7b 31 7d 22 29 2c 20 66 75 6e 28 5b 5d 2c 69  ){1}"), fun([],i
1d40: 6e 74 6c 28 31 29 29 29 3b 0d 0a 09 61 73 73 65  ntl(1)));...asse
1d50: 72 74 5f 65 71 28 70 61 72 73 65 53 74 72 69 6e  rt_eq(parseStrin
1d60: 67 28 22 5c 75 30 33 42 42 28 78 29 7b 31 7d 22  g("\u03BB(x){1}"
1d70: 29 2c 20 66 75 6e 28 5b 22 78 22 5d 2c 69 6e 74  ), fun(["x"],int
1d80: 6c 28 31 29 29 29 3b 0d 0a 09 61 73 73 65 72 74  l(1)));...assert
1d90: 5f 65 71 28 70 61 72 73 65 53 74 72 69 6e 67 28  _eq(parseString(
1da0: 60 31 3b 32 60 29 2c 20 6c 65 74 28 22 5f 22 2c  `1;2`), let("_",
1db0: 22 22 2c 69 6e 74 6c 28 31 29 2c 69 6e 74 6c 28  "",intl(1),intl(
1dc0: 32 29 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f 65  2)));...assert_e
1dd0: 71 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 31  q(parseString(`1
1de0: 3b 32 3b 60 29 2c 20 6c 65 74 28 22 5f 22 2c 22  ;2;`), let("_","
1df0: 22 2c 69 6e 74 6c 28 31 29 2c 69 6e 74 6c 28 32  ",intl(1),intl(2
1e00: 29 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f 65 71  )));...assert_eq
1e10: 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 6c 65  (parseString(`le
1e20: 74 20 78 3d 31 3b 32 60 29 2c 20 6c 65 74 28 22  t x=1;2`), let("
1e30: 78 22 2c 22 22 2c 69 6e 74 6c 28 31 29 2c 69 6e  x","",intl(1),in
1e40: 74 6c 28 32 29 29 29 3b 0d 0a 09 61 73 73 65 72  tl(2)));...asser
1e50: 74 5f 65 71 28 70 61 72 73 65 53 74 72 69 6e 67  t_eq(parseString
1e60: 28 60 76 61 72 20 78 3d 31 3b 32 3b 60 29 2c 20  (`var x=1;2;`), 
1e70: 6c 65 74 28 22 78 22 2c 22 22 2c 69 6e 74 6c 28  let("x","",intl(
1e80: 31 29 2c 69 6e 74 6c 28 32 29 29 29 3b 0d 0a 09  1),intl(2)));...
1e90: 61 73 73 65 72 74 5f 65 71 28 70 61 72 73 65 53  assert_eq(parseS
1ea0: 74 72 69 6e 67 28 60 64 65 66 20 78 3d 31 60 29  tring(`def x=1`)
1eb0: 2c 20 6c 65 74 28 22 78 22 2c 22 22 2c 69 6e 74  , let("x","",int
1ec0: 6c 28 31 29 2c 76 61 72 28 22 78 22 29 29 29 3b  l(1),var("x")));
1ed0: 0d 0a 09 61 73 73 65 72 74 5f 65 71 28 70 61 72  ...assert_eq(par
1ee0: 73 65 53 74 72 69 6e 67 28 60 40 76 61 6c 20 78  seString(`@val x
1ef0: 3d 31 3b 60 29 2c 20 6c 65 74 28 22 78 22 2c 22  =1;`), let("x","
1f00: 40 76 61 6c 22 2c 69 6e 74 6c 28 31 29 2c 76 61  @val",intl(1),va
1f10: 72 28 22 78 22 29 29 29 3b 0d 0a 09 61 73 73 65  r("x")));...asse
1f20: 72 74 5f 65 71 28 70 61 72 73 65 53 74 72 69 6e  rt_eq(parseStrin
1f30: 67 28 60 40 74 79 70 20 78 3d 22 23 69 6e 74 22  g(`@typ x="#int"
1f40: 3b 60 29 2c 20 6c 65 74 28 22 78 22 2c 22 40 74  ;`), let("x","@t
1f50: 79 70 22 2c 73 74 72 6c 28 22 23 69 6e 74 22 29  yp",strl("#int")
1f60: 2c 76 61 72 28 22 78 22 29 29 29 3b 0d 0a 09 61  ,var("x")));...a
1f70: 73 73 65 72 74 5f 65 71 28 70 61 72 73 65 53 74  ssert_eq(parseSt
1f80: 72 69 6e 67 28 60 66 28 31 2c 32 29 60 29 2c 20  ring(`f(1,2)`), 
1f90: 63 61 6c 6c 28 76 61 72 28 22 66 22 29 2c 69 6e  call(var("f"),in
1fa0: 74 6c 28 31 29 2c 69 6e 74 6c 28 32 29 29 29 3b  tl(1),intl(2)));
1fb0: 0d 0a 09 61 73 73 65 72 74 5f 65 71 28 70 61 72  ...assert_eq(par
1fc0: 73 65 53 74 72 69 6e 67 28 60 69 66 28 31 29 7b  seString(`if(1){
1fd0: 32 7d 60 29 2c 20 63 61 6c 6c 28 76 61 72 28 22  2}`), call(var("
1fe0: 69 66 22 29 2c 69 6e 74 6c 28 31 29 2c 66 75 6e  if"),intl(1),fun
1ff0: 28 5b 5d 2c 69 6e 74 6c 28 32 29 29 2c 66 75 6e  ([],intl(2)),fun
2000: 28 5b 5d 2c 69 6e 74 6c 28 31 37 38 29 29 29 29  ([],intl(178))))
2010: 3b 0d 0a 09 61 73 73 65 72 74 5f 65 71 28 70 61  ;...assert_eq(pa
2020: 72 73 65 53 74 72 69 6e 67 28 60 69 66 28 31 29  rseString(`if(1)
2030: 7b 32 7d 65 6c 73 65 7b 33 7d 60 29 2c 20 63 61  {2}else{3}`), ca
2040: 6c 6c 28 76 61 72 28 22 69 66 22 29 2c 69 6e 74  ll(var("if"),int
2050: 6c 28 31 29 2c 66 75 6e 28 5b 5d 2c 69 6e 74 6c  l(1),fun([],intl
2060: 28 32 29 29 2c 66 75 6e 28 5b 5d 2c 69 6e 74 6c  (2)),fun([],intl
2070: 28 33 29 29 29 29 3b 0d 0a 09 61 73 73 65 72 74  (3))));...assert
2080: 5f 65 71 28 70 61 72 73 65 53 74 72 69 6e 67 28  _eq(parseString(
2090: 60 69 66 28 31 29 7b 7d 65 6c 73 65 7b 33 7d 28  `if(1){}else{3}(
20a0: 29 28 29 60 29 2c 0d 0a 09 09 63 61 6c 6c 28 63  )()`),....call(c
20b0: 61 6c 6c 28 63 61 6c 6c 28 76 61 72 28 22 69 66  all(call(var("if
20c0: 22 29 2c 69 6e 74 6c 28 31 29 2c 66 75 6e 28 5b  "),intl(1),fun([
20d0: 5d 2c 69 6e 74 6c 28 31 37 38 29 29 2c 66 75 6e  ],intl(178)),fun
20e0: 28 5b 5d 2c 69 6e 74 6c 28 33 29 29 29 29 29 29  ([],intl(3))))))
20f0: 3b 0d 0a 09 61 73 73 65 72 74 5f 65 71 28 70 61  ;...assert_eq(pa
2100: 72 73 65 53 74 72 69 6e 67 28 60 31 2b 32 2a 33  rseString(`1+2*3
2110: 60 29 2c 20 63 61 6c 6c 28 76 61 72 28 22 2b 22  `), call(var("+"
2120: 29 2c 69 6e 74 6c 28 31 29 2c 63 61 6c 6c 28 76  ),intl(1),call(v
2130: 61 72 28 22 2a 22 29 2c 69 6e 74 6c 28 32 29 2c  ar("*"),intl(2),
2140: 69 6e 74 6c 28 33 29 29 29 29 3b 0d 0a 09 61 73  intl(3))));...as
2150: 73 65 72 74 5f 65 71 28 70 61 72 73 65 53 74 72  sert_eq(parseStr
2160: 69 6e 67 28 60 28 31 2b 32 29 2a 33 60 29 2c 20  ing(`(1+2)*3`), 
2170: 63 61 6c 6c 28 76 61 72 28 22 2a 22 29 2c 63 61  call(var("*"),ca
2180: 6c 6c 28 76 61 72 28 22 2b 22 29 2c 69 6e 74 6c  ll(var("+"),intl
2190: 28 31 29 2c 69 6e 74 6c 28 32 29 29 2c 69 6e 74  (1),intl(2)),int
21a0: 6c 28 33 29 29 29 3b 0d 0a 09 61 73 73 65 72 74  l(3)));...assert
21b0: 5f 65 71 28 70 61 72 73 65 53 74 72 69 6e 67 28  _eq(parseString(
21c0: 60 31 2a 28 32 2b 33 29 60 29 2c 20 63 61 6c 6c  `1*(2+3)`), call
21d0: 28 76 61 72 28 22 2a 22 29 2c 69 6e 74 6c 28 31  (var("*"),intl(1
21e0: 29 2c 63 61 6c 6c 28 76 61 72 28 22 2b 22 29 2c  ),call(var("+"),
21f0: 69 6e 74 6c 28 32 29 2c 69 6e 74 6c 28 33 29 29  intl(2),intl(3))
2200: 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f 65 71 28  ));...assert_eq(
2210: 70 61 72 73 65 53 74 72 69 6e 67 28 60 31 2a 32  parseString(`1*2
2220: 2b 33 60 29 2c 20 63 61 6c 6c 28 76 61 72 28 22  +3`), call(var("
2230: 2b 22 29 2c 63 61 6c 6c 28 76 61 72 28 22 2a 22  +"),call(var("*"
2240: 29 2c 69 6e 74 6c 28 31 29 2c 69 6e 74 6c 28 32  ),intl(1),intl(2
2250: 29 29 2c 69 6e 74 6c 28 33 29 29 29 3b 0d 0a 09  )),intl(3)));...
2260: 61 73 73 65 72 74 5f 65 71 28 70 61 72 73 65 53  assert_eq(parseS
2270: 74 72 69 6e 67 28 60 40 78 28 31 29 60 29 2c 20  tring(`@x(1)`), 
2280: 6c 61 79 28 22 40 78 22 2c 20 69 6e 74 6c 28 31  lay("@x", intl(1
2290: 29 29 29 3b 0d 0a 0d 0a 09 61 73 73 65 72 74 5f  )));.....assert_
22a0: 65 71 28 70 61 72 73 65 53 74 72 69 6e 67 28 60  eq(parseString(`
22b0: 0d 0a 09 09 6c 65 74 20 78 20 3d 20 31 30 30 3b  ....let x = 100;
22c0: 20 23 63 6f 6d 6d 65 6e 74 0d 0a 09 09 6c 65 74   #comment....let
22d0: 20 79 20 3d 20 32 30 30 3b 20 23 63 6f 6d 6d 65   y = 200; #comme
22e0: 6e 74 21 21 21 21 21 0d 0a 09 09 09 78 2b 79 0d  nt!!!!!.....x+y.
22f0: 0a 09 60 29 2c 0d 0a 09 09 6c 65 74 28 22 78 22  ..`),....let("x"
2300: 2c 20 22 22 2c 20 69 6e 74 6c 28 31 30 30 29 2c  , "", intl(100),
2310: 20 6c 65 74 28 22 79 22 2c 20 22 22 2c 20 69 6e   let("y", "", in
2320: 74 6c 28 32 30 30 29 2c 20 63 61 6c 6c 28 76 61  tl(200), call(va
2330: 72 28 22 2b 22 29 2c 20 76 61 72 28 22 78 22 29  r("+"), var("x")
2340: 2c 20 76 61 72 28 22 79 22 29 29 29 29 0d 0a 09  , var("y"))))...
2350: 29 3b 0d 0a 0d 0a 09 61 73 73 65 72 74 5f 65 71  );.....assert_eq
2360: 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 0d 0a  (parseString(`..
2370: 09 09 76 61 72 20 66 61 63 20 3d 20 66 75 6e 28  ..var fac = fun(
2380: 78 29 7b 20 69 66 28 78 20 3c 3d 20 31 29 20 7b  x){ if(x <= 1) {
2390: 31 7d 20 65 6c 73 65 20 7b 78 2a 66 61 63 28 78  1} else {x*fac(x
23a0: 2d 31 29 7d 20 7d 3b 0d 0a 09 09 66 61 63 28 31  -1)} };....fac(1
23b0: 30 29 0d 0a 09 60 29 2c 0d 0a 09 09 6c 65 74 28  0)...`),....let(
23c0: 22 66 61 63 22 2c 20 22 22 2c 20 66 75 6e 28 5b  "fac", "", fun([
23d0: 22 78 22 5d 2c 0d 0a 09 09 09 63 61 6c 6c 28 76  "x"],.....call(v
23e0: 61 72 28 22 69 66 22 29 2c 0d 0a 09 09 09 09 63  ar("if"),......c
23f0: 61 6c 6c 28 76 61 72 28 22 3c 3d 22 29 2c 20 76  all(var("<="), v
2400: 61 72 28 22 78 22 29 2c 20 69 6e 74 6c 28 31 29  ar("x"), intl(1)
2410: 29 2c 0d 0a 09 09 09 09 66 75 6e 28 5b 5d 2c 20  ),......fun([], 
2420: 69 6e 74 6c 28 31 29 29 2c 0d 0a 09 09 09 09 66  intl(1)),......f
2430: 75 6e 28 5b 5d 2c 20 63 61 6c 6c 28 76 61 72 28  un([], call(var(
2440: 22 2a 22 29 2c 20 76 61 72 28 22 78 22 29 2c 20  "*"), var("x"), 
2450: 63 61 6c 6c 28 76 61 72 28 22 66 61 63 22 29 2c  call(var("fac"),
2460: 63 61 6c 6c 28 76 61 72 28 22 2d 22 29 2c 76 61  call(var("-"),va
2470: 72 28 22 78 22 29 2c 69 6e 74 6c 28 31 29 29 29  r("x"),intl(1)))
2480: 29 29 0d 0a 09 09 09 29 29 2c 0d 0a 09 09 09 63  )).....)),.....c
2490: 61 6c 6c 28 76 61 72 28 22 66 61 63 22 29 2c 69  all(var("fac"),i
24a0: 6e 74 6c 28 31 30 29 29 0d 0a 09 09 29 0d 0a 09  ntl(10))....)...
24b0: 29 3b 0d 0a 7d 0d 0a 0d 0a 75 6e 69 74 74 65 73  );..}....unittes
24c0: 74 0d 0a 7b 0d 0a 09 61 73 73 65 72 74 5f 74 68  t..{...assert_th
24d0: 72 6f 77 21 55 6e 65 78 70 65 63 74 65 64 45 4f  row!UnexpectedEO
24e0: 46 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 31  F(parseString(`1
24f0: 2b 60 29 29 3b 0d 0a 09 61 73 73 65 72 74 5f 74  +`));...assert_t
2500: 68 72 6f 77 21 50 61 72 73 65 45 78 63 65 70 74  hrow!ParseExcept
2510: 69 6f 6e 28 70 61 72 73 65 53 74 72 69 6e 67 28  ion(parseString(
2520: 60 31 2b 32 7d 60 29 29 3b 0d 0a 09 61 73 73 65  `1+2}`));...asse
2530: 72 74 5f 74 68 72 6f 77 21 55 6e 65 78 70 65 63  rt_throw!Unexpec
2540: 74 65 64 45 4f 46 28 70 61 72 73 65 53 74 72 69  tedEOF(parseStri
2550: 6e 67 28 60 6c 65 74 20 22 78 22 60 29 29 3b 0d  ng(`let "x"`));.
2560: 0a 09 61 73 73 65 72 74 5f 74 68 72 6f 77 21 55  ..assert_throw!U
2570: 6e 65 78 70 65 63 74 65 64 45 4f 46 28 70 61 72  nexpectedEOF(par
2580: 73 65 53 74 72 69 6e 67 28 60 76 61 72 60 29 29  seString(`var`))
2590: 3b 0d 0a 09 61 73 73 65 72 74 5f 74 68 72 6f 77  ;...assert_throw
25a0: 21 50 61 72 73 65 45 78 63 65 70 74 69 6f 6e 28  !ParseException(
25b0: 70 61 72 73 65 53 74 72 69 6e 67 28 60 40 76 61  parseString(`@va
25c0: 6c 20 78 20 3d 3d 60 29 29 3b 0d 0a 09 61 73 73  l x ==`));...ass
25d0: 65 72 74 5f 74 68 72 6f 77 21 50 61 72 73 65 45  ert_throw!ParseE
25e0: 78 63 65 70 74 69 6f 6e 28 70 61 72 73 65 53 74  xception(parseSt
25f0: 72 69 6e 67 28 60 69 66 28 29 7b 31 7d 60 29 29  ring(`if(){1}`))
2600: 3b 0d 0a 09 61 73 73 65 72 74 5f 74 68 72 6f 77  ;...assert_throw
2610: 21 55 6e 65 78 70 65 63 74 65 64 45 4f 46 28 70  !UnexpectedEOF(p
2620: 61 72 73 65 53 74 72 69 6e 67 28 60 66 28 60 29  arseString(`f(`)
2630: 29 3b 0d 0a 7d 0d 0a 0d 0a 75 6e 69 74 74 65 73  );..}....unittes
2640: 74 0d 0a 7b 0d 0a 09 6d 69 78 69 6e 20 45 61 73  t..{...mixin Eas
2650: 79 41 53 54 3b 0d 0a 09 61 73 73 65 72 74 5f 65  yAST;...assert_e
2660: 71 28 70 61 72 73 65 53 74 72 69 6e 67 28 60 64  q(parseString(`d
2670: 65 66 20 66 6f 6f 28 78 29 20 7b 20 78 2b 31 20  ef foo(x) { x+1 
2680: 7d 3b 20 66 6f 6f 60 29 2c 0d 0a 09 09 6c 65 74  }; foo`),....let
2690: 28 22 66 6f 6f 22 2c 20 22 22 2c 0d 0a 09 09 09  ("foo", "",.....
26a0: 66 75 6e 28 5b 22 78 22 5d 2c 20 63 61 6c 6c 28  fun(["x"], call(
26b0: 76 61 72 28 22 2b 22 29 2c 20 76 61 72 28 22 78  var("+"), var("x
26c0: 22 29 2c 20 69 6e 74 6c 28 31 29 29 29 2c 0d 0a  "), intl(1))),..
26d0: 09 09 09 76 61 72 28 22 66 6f 6f 22 29 29 0d 0a  ...var("foo"))..
26e0: 09 29 3b 0d 0a 7d 0d 0a                          .);..}..