World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
Carl 4-Feb-2008 [2340] | In R3 variables are more protected than in R2. But, perhaps we can do something with temporaries on stack that require fewer tests, but have limited usage patterns. |
Pekr 4-Feb-2008 [2341] | But weeee want RebCode. Hopefully it comes. Even if slower than R2 version. We will see - maybe C based plug-ins and proper porting efforts have more sense, dunno ... |
Geomol 5-Feb-2008 [2342] | I finished v. 1.0.0 of 6502 assembler: http://www.fys.ku.dk/~niclasen/rebol/language/asm6502.r It defines the asm6502 function, which take 6502 assembler as text input and produces 6502 machine code (opcodes). Might be a good example of parsing in REBOL. |
btiffin 5-Feb-2008 [2343] | Go John Go! |
Geomol 5-Feb-2008 [2344] | :) |
Graham 5-Feb-2008 [2345] | Oh ...I thought we were going to see a 6502 emulator! |
Geomol 5-Feb-2008 [2346] | One step at a time! |
Graham 5-Feb-2008 [2347] | single stepping? |
Geomol 5-Feb-2008 [2348x3] | Yeah, I'm only a level 1multitasker or so. |
You see, now I have a 6502 assembler written in REBOL, so now it will be easy for me to test a 6502 emulator, while I'm writing it. | |
I've found, that it's best to test while I develop. It's traditionally design-programming-test. I don't find this the best way, if you want fast progress and few errors. | |
btiffin 5-Feb-2008 [2351] | Agreed; write a line, test a line. Personal comment: Then forget you wrote it so a few days later you can write a line, test a line and then go "whoa, deja-vu" :) |
Gregg 5-Feb-2008 [2352] | Since it's line-based, could the syntax error tell you which line, in addition to what op it's near? |
Geomol 5-Feb-2008 [2353x2] | Yes, for the syntax errors it's fixed now: http://www.fys.ku.dk/~niclasen/rebol/language/asm6502.r For labels not found, you have to search you source, where you branch to that label. |
It's a one pass assembler and then some. After first pass, it checks, if there is forward referencing to labels and then fix those relative addresses directly in the produced code. Should be fast, as it's not a completely two-pass. | |
Gregg 5-Feb-2008 [2355] | I haven't played with it, but it's still veyr impressive for such a short project. |
Geomol 5-Feb-2008 [2356] | It's about 10k REBOL source. 2644 bytes compressed. It amuses me to use REBOL for things like this. The most enjoyable language around! It took me like 3 halves evenings. |
btiffin 5-Feb-2008 [2357] | Elite, John. Elite. |
Geomol 5-Feb-2008 [2358x7] | Instructions can be separated by : on the same line, and comments put at the end. Example: asm6502 "inx:iny This is a comment!" UPPER/lower case can be used: asm6502 "INX : INY This is a comment!" |
btiffin, hehe :) | |
The asm6502 can take the refinement /at to tell the starting address in the 64kb ram area for the produced code. I don't like the refinement being called /at, because we already have the word AT. Any suggestions for a better name? | |
The Program Counter get set to the argument for that refinement, else 1, if the refinement isn't there. | |
So it could be named something like: /pc /target /address /start ... | |
/begin maybe? | |
Or I should just stick with /at, because that's the word, we usually use to position ourselves within a series. (And the ram can be seen as a series.) | |
btiffin 5-Feb-2008 [2365] | /skip would be the rebolious name I think, but /org would resonate with me as well. |
Graham 5-Feb-2008 [2366] | Elite was done on the C64 as well as other computers of that era, so would have been done in 6502 assembler. |
Geomol 6-Feb-2008 [2367] | Yes! :) From http://www.bbcmicrogames.com/acornsoft.html It has been ported to just about every other platform out there however, it appeared first on the BBC. The BBC had a 6502 too, and it's the platform, I'm testing up against, so let's hope, it all work out well. |
Gregg 6-Feb-2008 [2368] | /at is probably fine. |
Robert 8-Feb-2008 [2369] | Is there an emulator for this Elite release? |
Henrik 8-Feb-2008 [2370] | I'm a little stuck here with a simple problem: a: func [v] [ parse v [ any [ 'a (prin "a") | 'b (prin "b") | 'c (prin "c") (prin "-") ] ] ] >> a [a b c c a] abc-c-a I want to print the dash after every letter. Do I have to include it after each word? |
Oldes 8-Feb-2008 [2371x2] | a: func [v] [ parse v [ any [ [ 'a (prin "a") | ['b (prin "b")] | ['c (prin "c")] ] (prin "-") ] ] ] |
a: func [v] [ parse v [ any [ [ 'a (prin "a") | 'b (prin "b") | 'c (prin "c") ] (prin "-") ] ] ] | |
Henrik 8-Feb-2008 [2373] | beautiful, thanks |
Geomol 8-Feb-2008 [2374] | Robert, there's no emulator written in REBOL, that can run Elite, afaik. But there are emulators emulating the BBC computer, if that's what you mean, and they can run Elite. I use an emulator called BeebEm3. |
PatrickP61 23-Feb-2008 [2375x2] | I have a question on the above parse by Oldes on Feb 8th. If you feed in a [a b c d e f] you will get a-b-c-==false How can you change the parse so that it will put a dash in between all characters, without defining each character? |
Now that I think of it, I would not even use a parse to do that. But what could I do if I wanted only a subset of characters to show up without defining them all | |
BrianH 23-Feb-2008 [2377] | Patrick, in answer to your first question: parse [a b c d e f] [ set x word! (prin form x) any [set x word! (prin join "-" form x)] ] |
PatrickP61 23-Feb-2008 [2378] | Super -- Thanks for the info. I'm still learning about parse! |
BrianH 23-Feb-2008 [2379] | You have to remember to structure your rules using LL style. Do you notice that I checked for one word first, then looped over the subsequent words? That was to avoid putting the "-" after the last word as well. Parse uses right recursion - not like yacc, which uses left recursion. |
PatrickP61 23-Feb-2008 [2380] | I was just wondering about the trailing dash, but thought that could be handled in a different step. Your method is cleaner. |
BrianH 23-Feb-2008 [2381x2] | replace/all form [a b c d e f] " " "-" |
Cleaner yet. | |
JohanAR 2-Mar-2008 [2383] | Can anyone help me why the following appears to work, but still returns false? data: [ table [1 2 3] [4 5 6] ] parse data ['table some into [ some [ set n integer! (print n) ] (print "-")] ] |
Graham 2-Mar-2008 [2384] | do you need an 'end ? |
JohanAR 2-Mar-2008 [2385x2] | just found out that this seems to work, but I don't really see why I have to include end. As I've understood "into" is supposed to fail and continue if the next item isn't a block! parse data ['table some into [ end | some [ set n integer! (print n) ] (print "-") ] ] |
Ahh, another block around the into statement did the trick :P Thanks for the help though parse data ['table some [ into [ some [ set n integer! (print n) ] (print "-") ] ] ] | |
[unknown: 5] 4-Mar-2008 [2387x3] | shouldn't datatype! be included in rule block parsing? |
how do you do this: blk: ["somestring" string!] We can't do: parse blk [string! datatype!] and get a match. | |
I see I can do a reduce on the blk when passed to parse and get it true but not sure that is safe for my situation. | |
older newer | first last |