1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2025-01-10 17:31:18 +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
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.
| 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 = do
@ -46,7 +48,7 @@ toplevel = do
decl :: Parser Decl
decl = do
d <- (try assign <|> try reserve <|> try external)
optional comment
optional_comment_before_eol
return d
reserve :: Parser Decl
@ -98,22 +100,19 @@ block :: Parser [Instruction]
block = do
string "{"
spaces
optional comment
cs <- many commented_command
string "}"
spaces
return cs
optional_comment = do
optional_comment_before_eol = do
optional comment
nspaces
comment :: Parser ()
comment = do
string ";"
manyTill anyChar (try (string "\n"))
spaces
return ()
-- -- -- -- -- -- commands -- -- -- -- --
@ -186,7 +185,7 @@ addressing_mode opcode f = do
commented_command :: Parser Instruction
commented_command = do
c <- command
optional comment
optional_comment_before_eol
return c
command :: Parser Instruction