1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2025-08-19 03:27:28 +00:00

Baby steps.

This commit is contained in:
Cat's Eye Technologies
2014-04-03 19:54:01 +01:00
parent 569de53797
commit 962f2ad452
2 changed files with 6 additions and 15 deletions

View File

@@ -23,14 +23,6 @@ Checking SixtyPical Programs
| } | }
? missing 'main' routine ? missing 'main' routine
A comment may appear at the start of a block.
| routine main {
| ; this program does nothing
| nop
| }
= True
A comment may appear after each command. A comment may appear after each command.
| routine main { | routine main {

View File

@@ -35,7 +35,9 @@ Branch := "bcc" | "bcs" | "beq" | "bmi" | "bne" | "bpl" | "bvc" | "bvs".
-} -}
nspaces = many (oneOf " \t") nspaces :: Parser [Char]
nspaces = do
many (char ' ' <|> char '\t')
toplevel :: Parser Program toplevel :: Parser Program
toplevel = do toplevel = do
@@ -46,7 +48,7 @@ toplevel = do
decl :: Parser Decl decl :: Parser Decl
decl = do decl = do
d <- (try assign <|> try reserve <|> try external) d <- (try assign <|> try reserve <|> try external)
optional comment optional_comment_before_eol
return d return d
reserve :: Parser Decl reserve :: Parser Decl
@@ -98,22 +100,19 @@ block :: Parser [Instruction]
block = do block = do
string "{" string "{"
spaces spaces
optional comment
cs <- many commented_command cs <- many commented_command
string "}" string "}"
spaces spaces
return cs return cs
optional_comment = do optional_comment_before_eol = do
optional comment optional comment
nspaces
comment :: Parser () comment :: Parser ()
comment = do comment = do
string ";" string ";"
manyTill anyChar (try (string "\n")) manyTill anyChar (try (string "\n"))
spaces spaces
return ()
-- -- -- -- -- -- commands -- -- -- -- -- -- -- -- -- -- -- commands -- -- -- -- --
@@ -186,7 +185,7 @@ addressing_mode opcode f = do
commented_command :: Parser Instruction commented_command :: Parser Instruction
commented_command = do commented_command = do
c <- command c <- command
optional comment optional_comment_before_eol
return c return c
command :: Parser Instruction command :: Parser Instruction