World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
Geomol 5-Feb-2008 [2364] | 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 [2387x4] | 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. | |
be nice if there was a lit-type! | |
Henrik 4-Mar-2008 [2391x2] | string! is considered a word here. you must provide the datatype in its serialized state: parse ["something" #[datatype string!]] [string! datatype!] |
same if you use none or other things that would be considered words in an unreduced block. | |
[unknown: 5] 4-Mar-2008 [2393x2] | I don't get what you mean by serialized state |
>> parse ["something" #[datatype string!]] [string! datatype!] ** Syntax Error: Invalid construct -- #[ ** Near: (line 1) parse ["something" #[datatype string!]] [string! datatype!] | |
Henrik 4-Mar-2008 [2395] | >> blk: ["something" string!] == ["something" string!] >> type? second blk == word! >> type? second reduce blk == datatype! ; this you know, right? OK... |
[unknown: 5] 4-Mar-2008 [2396x5] | I guess you mean datatype! with the "!" |
yes Henrik | |
What I'm trying to avoid is any reducing | |
I dont' want any execution of code as I don't know what might be passed by the user | |
But I still need to validate the passed block | |
Henrik 4-Mar-2008 [2401] | >> mold/all string! == "#[datatype! string!]" >> blk: ["something" #[datatype! string!]] == ["something" string!] >> type? second blk == datatype! ; voila :-) |
[unknown: 5] 4-Mar-2008 [2402x3] | didn't know mold/all did that for string! |
cool Henrik | |
I think that could work | |
Henrik 4-Mar-2008 [2405] | your "lit-datatype" is actually serialization. it exists for everything that otherwise would lose its datatype inside a block |
[unknown: 5] 4-Mar-2008 [2406] | nice. |
Henrik 4-Mar-2008 [2407] | mold/all will display how to serialize something so you don't need to reduce a block to get the right datatype in there. |
[unknown: 5] 4-Mar-2008 [2408] | yeah I see which is exactly what I'm looking for. |
Henrik 4-Mar-2008 [2409x2] | >> type? first [none] == word! >> type? first [#[none]] == none! |
a great and valuable tool (also speeds some things up) | |
[unknown: 5] 4-Mar-2008 [2411x3] | yeah I knew that one but didn't think about that for datatypes. |
Yes greatly | |
It's gonna help me for what I'm doing. | |
older newer | first last |