mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-22 17:32:01 +00:00
Allow comments.
This commit is contained in:
parent
159d3835be
commit
1cf166f0db
@ -262,7 +262,6 @@ In these, `absolute` must be a `reserve`d or `locate`d address.
|
||||
TODO
|
||||
----
|
||||
|
||||
* comments
|
||||
* Initial values for reserved, incl. tables
|
||||
* give length for tables, must be there for reserved
|
||||
* Character tables ("strings" to everybody else)
|
||||
@ -295,6 +294,25 @@ Tests
|
||||
| }
|
||||
? 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 {
|
||||
| lda #1 ; we assemble the fnord using
|
||||
| ldx #1 ; multiple lorem ipsums which
|
||||
| ldy #1
|
||||
| lda #1 ; we
|
||||
| ldx #1 ; found under the bridge by the old mill yesterday
|
||||
| }
|
||||
= True
|
||||
|
||||
A program may `reserve` and `assign`.
|
||||
|
||||
| reserve byte lives
|
||||
|
@ -16,7 +16,7 @@ Decl := "reserve" StorageType LocationName
|
||||
| "external" RoutineName Address.
|
||||
StorageType := "byte" | "word" | "vector".
|
||||
Routine := "routine" RoutineName Block.
|
||||
Block := "{" {Command} "}".
|
||||
Block := "{" [Comment] {Command [Comment]} "}".
|
||||
Command := "if" Branch Block "else" Block
|
||||
| "lda" (LocationName | Immediate)
|
||||
| "ldx" (LocationName | Immediate)
|
||||
@ -90,11 +90,19 @@ block :: Parser [Instruction]
|
||||
block = do
|
||||
string "{"
|
||||
spaces
|
||||
cs <- many command
|
||||
optional comment
|
||||
cs <- many commented_command
|
||||
string "}"
|
||||
spaces
|
||||
return cs
|
||||
|
||||
comment :: Parser ()
|
||||
comment = do
|
||||
string ";"
|
||||
manyTill anyChar (try (string "\n"))
|
||||
spaces
|
||||
return ()
|
||||
|
||||
-- -- -- -- -- -- commands -- -- -- -- --
|
||||
|
||||
immediate :: (DataValue -> Instruction) -> Parser Instruction
|
||||
@ -124,6 +132,12 @@ absolute_indexed f = do
|
||||
indexes <- many index
|
||||
return $ f l indexes
|
||||
|
||||
commented_command :: Parser Instruction
|
||||
commented_command = do
|
||||
c <- command
|
||||
optional comment
|
||||
return c
|
||||
|
||||
command :: Parser Instruction
|
||||
command = (try lda) <|>
|
||||
(try ldx) <|> (try ldy) <|>
|
||||
|
Loading…
Reference in New Issue
Block a user