From 108c46fb8cf1e8bf01e5e4bf34492f54a82f5592 Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Fri, 11 May 2012 16:27:46 -0400 Subject: [PATCH] Fixed terminator recognition in lexer --- example.dl | 18 ++++++++++++++---- source/dllexer/dllexer.cpp | 10 +++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/example.dl b/example.dl index 70fe059..5e6ad1b 100644 --- a/example.dl +++ b/example.dl @@ -51,6 +51,7 @@ end # If statement if conditional if_branch +else else_branch end @@ -64,13 +65,22 @@ end (1 add (1 add 1)) (1 - (1 + 1)) +## Define an infix operator (No Precedence) +#infix = +# +## Define dummy keywords (Whitespace) +#keyword ; +# +#foo = (1 + 1) ; + # Macros macro let (:= =) ; (a := b) - define a b end + define a b + (a = b) - set! a b end + set! a b end -let foo := "bar" end -let foo = 5 end +let foo := "bar" ; +let foo = 5 ; diff --git a/source/dllexer/dllexer.cpp b/source/dllexer/dllexer.cpp index 8b1cbca..15f2781 100644 --- a/source/dllexer/dllexer.cpp +++ b/source/dllexer/dllexer.cpp @@ -47,6 +47,7 @@ std::string DLLexer::terminator(void) Token DLLexer::next(void) { Token ret; + bool escaped = false; // Prime the buffer. For empty input strings this results in us finding // the EOF and skipping the loop @@ -111,7 +112,6 @@ Token DLLexer::next(void) // Everything else (except the unescaped terminator) is considered an ID else { - bool escaped = false; if ( lookahead(1) == '\\' ) { consume(); @@ -119,11 +119,11 @@ Token DLLexer::next(void) } Id(ret); + } - if( !escaped && (ret.text().compare( terminator_string ) == 0) ) - { - ret.type( TERM ); - } + if( !escaped && (ret.text().compare( terminator_string ) == 0) ) + { + ret.type( TERM ); } } -- 2.52.0