mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-01-10 17:31:18 +00:00
Baby steps.
This commit is contained in:
parent
569de53797
commit
962f2ad452
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user