Skip to content

Commit

Permalink
Added the ability to write comments. Comments start with a ; and exte…
Browse files Browse the repository at this point in the history
…nd to the end of the line.
  • Loading branch information
kent committed Feb 13, 2014
1 parent a2404a1 commit 0a58fc1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion PyScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ PyToken* PyScanner::getToken() {
else if (c == '/') state = 8;
else if (c == '(') state = 9;
else if (c == ')') state = 10;
else if (c == ';') state = 12;
else if (c == -1) {
foundOne = true;
type = PYEOFTOKEN;
Expand Down Expand Up @@ -204,7 +205,15 @@ PyToken* PyScanner::getToken() {
type = PYBADTOKEN;
foundOne = true;
}

case 12:
// Comments extend to end of line and
// begin with a semicolon.
if (c == '\n' || c == -1) {
colCount = -1;
lineCount++;
state = 0;
lex = "";
}
}

if (!foundOne) {
Expand Down
4 changes: 3 additions & 1 deletion tests/raise.casm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
; This program raises an exception.

Function: main/0
Constants: None, "Hello World!"
Locals: ex
Expand All @@ -24,7 +26,7 @@ label00: DUP_TOP
POP_TOP
POP_BLOCK
POP_EXCEPT
LOAD_CONST 0
LOAD_CONST 0 ; here is a comment.
label01: LOAD_CONST 0
STORE_FAST 0
DELETE_FAST 0
Expand Down

0 comments on commit 0a58fc1

Please sign in to comment.