mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-17 22:30:27 +00:00
Character tables. Emit tables properly.
This commit is contained in:
parent
7a3b3b1b25
commit
ad1e159317
@ -211,7 +211,6 @@ it probably won't.)
|
|||||||
TODO
|
TODO
|
||||||
----
|
----
|
||||||
|
|
||||||
* Character tables ("strings" to everybody else)
|
|
||||||
* Addressing modes — indexed mode on more instructions
|
* Addressing modes — indexed mode on more instructions
|
||||||
* Rename and lift temporaries in nested blocks
|
* Rename and lift temporaries in nested blocks
|
||||||
* Tail-recursion optimization
|
* Tail-recursion optimization
|
||||||
|
@ -211,6 +211,22 @@ Reserving and assigning byte tables.
|
|||||||
= .space frequencies 16
|
= .space frequencies 16
|
||||||
= .alias screen 1024
|
= .alias screen 1024
|
||||||
|
|
||||||
|
Reserving things with initial values.
|
||||||
|
|
||||||
|
| reserve byte lives : 3
|
||||||
|
| reserve word screen : $0400
|
||||||
|
| reserve byte[8] frequencies : (0 1 2 4 5 8 9 10)
|
||||||
|
| reserve byte[13] message : "Hello, world!"
|
||||||
|
| routine main {
|
||||||
|
| }
|
||||||
|
= main:
|
||||||
|
= rts
|
||||||
|
=
|
||||||
|
= lives: .byte 3
|
||||||
|
= screen: .word 1024
|
||||||
|
= frequencies: .byte 0, 1, 2, 4, 5, 8, 9, 10
|
||||||
|
= message: .byte 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33
|
||||||
|
|
||||||
Temporary storage, in the form of block-local declarations. Note that these
|
Temporary storage, in the form of block-local declarations. Note that these
|
||||||
temporaries are not unioned yet, but they could be.
|
temporaries are not unioned yet, but they could be.
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
.charmap 'A, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
|
||||||
|
.charmap 'a, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
|
||||||
.org 0
|
.org 0
|
||||||
.word $0801
|
.word $0801
|
||||||
.data
|
.data
|
||||||
|
@ -37,7 +37,8 @@ emitDecl p (Reserve name (ByteTable size) vals) =
|
|||||||
name ++ ": .byte " ++ (showList vals)
|
name ++ ": .byte " ++ (showList vals)
|
||||||
where
|
where
|
||||||
showList [] = ""
|
showList [] = ""
|
||||||
showList (val:vals) = (show val) ++ " " ++ (showList vals)
|
showList [val] = show val
|
||||||
|
showList (val:vals) = (show val) ++ ", " ++ (showList vals)
|
||||||
|
|
||||||
emitDecl p (Reserve name typ [])
|
emitDecl p (Reserve name typ [])
|
||||||
| typ == Byte = ".space " ++ name ++ " 1"
|
| typ == Byte = ".space " ++ name ++ " 1"
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
module SixtyPical.Parser (parseProgram) where
|
module SixtyPical.Parser (parseProgram) where
|
||||||
|
|
||||||
import Numeric (readHex)
|
import Numeric (readHex)
|
||||||
|
import Data.Char (ord)
|
||||||
|
|
||||||
import Text.ParserCombinators.Parsec
|
import Text.ParserCombinators.Parsec
|
||||||
|
|
||||||
@ -115,7 +116,7 @@ storage_type = (try $ byte_table) <|> (storage "byte" Byte) <|>
|
|||||||
|
|
||||||
initial_value :: Parser [DataValue]
|
initial_value :: Parser [DataValue]
|
||||||
initial_value =
|
initial_value =
|
||||||
data_value_list <|> single_literal_data_value
|
data_value_list <|> string_literal <|> single_literal_data_value
|
||||||
where
|
where
|
||||||
single_literal_data_value = do
|
single_literal_data_value = do
|
||||||
a <- literal_data_value
|
a <- literal_data_value
|
||||||
@ -648,6 +649,13 @@ decimal_literal = do
|
|||||||
nspaces
|
nspaces
|
||||||
return $ read digits
|
return $ read digits
|
||||||
|
|
||||||
|
string_literal :: Parser [DataValue]
|
||||||
|
string_literal = do
|
||||||
|
char '"'
|
||||||
|
s <- manyTill anyChar (char '"')
|
||||||
|
nspaces
|
||||||
|
return $ map (\c -> ord c) s
|
||||||
|
|
||||||
-- -- -- driver -- -- --
|
-- -- -- driver -- -- --
|
||||||
|
|
||||||
parseProgram = parse toplevel ""
|
parseProgram = parse toplevel ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user