Differences From Artifact [f48294ade1f2cd3c]:
- File
polemy/parse.d
- 2010-11-09 06:02:32 - part of checkin [7de80acfb8] on branch trunk - Added ultra tenuki REPL (user: kinaba) [annotate]
To Artifact [c3f339e53d35901f]:
- File
polemy/parse.d
- 2010-11-09 06:19:11 - part of checkin [d78d700f7a] on branch trunk - tenuki REPL bug-fix (now we can continue using REPL after a syntax error) and file interpreter mode. (user: kinaba) [annotate]
11 11
12 /// Exception from this module 12 /// Exception from this module
13 13
14 class ParseException : Exception 14 class ParseException : Exception
15 { 15 {
16 const LexPosition pos; 16 const LexPosition pos;
17 17
18 this( const LexPosition pos, string msg, string file="", int line=0, Thr | 18 this( const LexPosition pos, string msg, string file=null, size_t line=0
19 { super(sprintf!"[%s] %s"(pos, msg), file, line, next); this.pos 19 { super(sprintf!"[%s] %s"(pos, msg), file, line, next); this.pos
20 } 20 }
21 21
22 private auto createException(Lexer)(Lexer lex, string msg) 22 private auto createException(Lexer)(Lexer lex, string msg)
23 { return new ParseException(lex.empty?null:lex.front.pos, msg); } 23 { return new ParseException(lex.empty?null:lex.front.pos, msg); }
24 24
25 /// Entry points of this module 25 /// Entry points of this module
26 26
27 auto parseString(S, T...)(S str, T fn_ln_cn) 27 auto parseString(S, T...)(S str, T fn_ln_cn)
28 { return parserFromString(str, fn_ln_cn).parse(); } 28 { return parserFromString(str, fn_ln_cn).parse(); }
29 29
30 auto parseFile(S, T...)(S filename, T ln_cn) 30 auto parseFile(S, T...)(S filename, T ln_cn)
31 { return parserFromString(filename, ln_cn).parse(); } | 31 { return parserFromFile(filename, ln_cn).parse(); }
32 32
33 /// Named Constructor of Parser 33 /// Named Constructor of Parser
34 34
35 private auto parserFromLexer(Lexer)(Lexer lex) 35 private auto parserFromLexer(Lexer)(Lexer lex)
36 { return new Parser!Lexer(lex); } 36 { return new Parser!Lexer(lex); }
37 37
38 private auto parserFromString(T...)(T params) 38 private auto parserFromString(T...)(T params)