@GiuseppeChillemi, lexical scanning is the first step. Parsing and tokenizing the input to find Red values in the text, and determining if the input is valid. That is, it contains all valid Red values.
At that point you have a block of values. Think about how you, as a human, interpret that. You know some values are direct values, like numbers. But what happens when you find a word? You need to determine what to do. What kind of word is it? What is the behavior of each kind of word?
Glad if it helped a bit @RiVeND.
Parse is deep, and hard to describe in prose/text, because the behavior and data mixture will be verbose. An interactive tool will be much better, so you can see what rule is being evaluated, the current location in the input, and maybe hints about keyword behavior. e.g. if
ahead is evaluated, a "does not advance" indicator could light up.
There was an old parsing tool, VisualParse++, from Sandstone technology, that did something like that. It was a shift-reduce parsing tool, and was pretty cool.
I'm new to the language and I'm trying to do something that I think is quite simple, but I fail.
I just want to convert a hexadecimal byte that is on string format to a binary value.
Something that works:
t: #"^(AB)" a: to binary! to-hex/size (to integer! t) 2 print a
I now want to "construct" t so that "AB" can be a string, ie construct a character from a string if that makes any sense.
I know that are other ways to do this but this got interesting.
construct a character from a string
A string is composed of characters, so such wording doesn't make much sense in this context. You might want to extract a character from a string rather.
>> t: "12345" == "12345" >> repeat a length? t [ print t/a ] *** Script Error: word! type is not allowed here *** Where: print *** Stack: >> repeat a length? t [ print t/(a) ] 1 2 3 4 5 >>
a, but inside parens
ais first evaluated to number and only then path is accessed. String is series, and you can access its elements by index numbers but not by literal words. Other structures can be accessed by words, e.g.:
>> t: [a b c] == [a b c] >> t/a == b >> t: #(a: 1 b: 2) == #( a: 1 b: 2 ) >> t/a == 1 >> t: object [a: 1 b: 2] == make object! [ a: 1 b: 2 ] >> t/a == 1
Thanks a lot! Was looking for something like "rejoin" , but I could not find it:http://static.red-lang.org/red-system-specs-light.html
on a side note - you shouldn't look at R/S docs, because they are not about Red, but about Red/System, a low level dialect. Here's a list of learning resources, but you also should get familiar with
@nd9600, there is no line information in errors. It would come up at times in the Rebol community, but I haven't seen it requested for Red yet. It's tricky, and Carl talked about it at one point, because there isn't always a concept of "lines". That is, Red doesn't need to maintain new line markers for processing in loaded code. Practically speaking, we use them a lot.
Greg, if Red code is just data , why can't the error indicate which element "#" in the series code block the error happened at?