Diff
Not logged in

Differences From Artifact [42c980cf31500e88]:

To Artifact [2739b95337ae2aab]:


5 * Parser for Polemy programming language 5 * Parser for Polemy programming language 6 */ 6 */ 7 module polemy.parse; 7 module polemy.parse; 8 import polemy._common; 8 import polemy._common; 9 import polemy.lex; 9 import polemy.lex; 10 import polemy.ast; 10 import polemy.ast; 11 11 12 /// Exception from this module | 12 /// 13 < 14 class ParseException : Exception 13 class ParseException : Exception 15 { 14 { 16 mixin ExceptionWithPosition; 15 mixin ExceptionWithPosition; 17 } 16 } 18 17 19 /// Entry points of this module 18 /// Entry points of this module 20 19 21 auto parseString(S, T...)(S str, T fn_ln_cn) | 20 AST parseString(S, T...)(S str, T fn_ln_cn) 22 { return parserFromString(str, fn_ln_cn).parse(); } 21 { return parserFromString(str, fn_ln_cn).parse(); } 23 22 > 23 /// Entry points of this module > 24 24 auto parseFile(S, T...)(S filename, T ln_cn) | 25 AST parseFile(S, T...)(S filename, T ln_cn) 25 { return parserFromFile(filename, ln_cn).parse(); } 26 { return parserFromFile(filename, ln_cn).parse(); } 26 27 27 /// Named Constructor of Parser | 28 // Named Constructors of Parser 28 29 29 private auto parserFromLexer(Lexer)(Lexer lex) 30 private auto parserFromLexer(Lexer)(Lexer lex) 30 { return new Parser!Lexer(lex); } 31 { return new Parser!Lexer(lex); } 31 32 32 private auto parserFromString(T...)(T params) 33 private auto parserFromString(T...)(T params) 33 { return parserFromLexer(polemy.lex.lexerFromString(params)); } 34 { return parserFromLexer(polemy.lex.lexerFromString(params)); } 34 35 35 private auto parserFromFile(T...)(T params) 36 private auto parserFromFile(T...)(T params) 36 { return parserFromLexer(polemy.lex.lexerFromFile(params)); } 37 { return parserFromLexer(polemy.lex.lexerFromFile(params)); } 37 38 38 /// Parser | 39 // Parser 39 40 40 private class Parser(Lexer) 41 private class Parser(Lexer) 41 if( isForwardRange!(Lexer) && is(ElementType!(Lexer) == Token) ) 42 if( isForwardRange!(Lexer) && is(ElementType!(Lexer) == Token) ) 42 { 43 { 43 AST parse() 44 AST parse() 44 { 45 { 45 auto e = Body(); 46 auto e = Body();