mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-08-19 03:27:28 +00:00
Baby steps.
This commit is contained in:
@@ -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 {
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user