r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Dialects] Questions about how to create dialects

DideC
13-Jan-2005
[51x2]
So, mix the both : the 'maxlength and 'default keywords :
rule: [
	'keyword (clear strings clear integers)

 any [set p integer! (append integers p) | set p string! (append strings 
 p)]

 (size: integers/1 maxlength: integers/2 caption: strings/1 default: 
 strings/2)

 any ['maxlength set p integer! (maxlength: p) | 'default set p string! 
 (default: p)]
]

tests: [
	[]
	[keyword]
	[keyword 10 20 "Blue" "Orange"]
	[keyword 10 "Blue"]
	[keyword 10 20]
	[keyword "Blue" "Orange"]
	[keyword 10 "Blue" 20 "Orange"]
	[keyword "Blue" 10 20 "Orange"]
	[keyword "Blue" "Orange" 10 20]
	[keyword "Blue" maxlength 20]
	[keyword 10 default "Orange"]
	[keyword maxlength 20]
	[keyword default "Orange"]
	[keyword maxlength 20 default "Orange"]
	[keyword default "Orange" maxlength 20]
]

strings: copy [] integers: copy []
size: maxlength: caption: default: -1

foreach t tests [
	parse t rule
	print [mold t "==>" size maxlength caption default]
]
Robert
14-Jan-2005
[53x2]
Dide, yes I have found the side effect of empty/1 == none! as well.
About mixing: I'm thinking of something like this:

(keyword: none)
any [

 opt ['maxlength (keyword: 'maxlength) | 'default (keyword: 'default)]]
	any [set p integer! (repend integers [keyword p])
	...

I think you get the idea.
Graham
14-Jan-2005
[55]
I had this problem a couple of weeks ago when trying to write a function 
to repopulate a web page from the posted cgi object.
Robert
14-Jan-2005
[56]
As said, my goal is to reduce the number of keywords as much as possible 
and make it easy to use.
Graham
14-Jan-2005
[57]
Are you trying to parse html to see if it is valid or not?
Robert
14-Jan-2005
[58]
No, I'm doing a dialect to create HTML forms with CGI etc.
Sunanda
14-Jan-2005
[59]
I suspect a mixed positonal + keyword approach may be the best.
Positional for for common attrbutes.
Keyword for the more esoteric ones.
Maybe read up on CSS shorthand methods for inspiration.
Robert
15-Jan-2005
[60]
Yes, right that's what I'm going to do. Thanks for the CSS tipp, 
I take a look at.
Geomol
25-Jan-2005
[61x2]
I've defined a new format, which is a REBOL version of XML. I already 
have scripts, that can convert between this format and XML. So far, 
I've called the functions "xml2rebol" and "rebol2xml", but maybe 
"rebol" isn't a good name for the new format. I've thought about 
"rebxml" as a name. Any ideas or suggestions? This is a quick explanation 
of the foremat:

tag (optional attributes) string or block

If the string is empty, it's an empty element tag. In XML: <tag/>

If attributes are present, they are one or more pairs of a word and 
a string.
A block can hold strings and new tags.

This XML example:

<person alive="yes"><name>Mr. Smith</name><male/><address><street>Sunnylane</street><number>44</number></address><person>
will look like this in the new format:

[ person alive "yes" [ name "Mr. Smith" male "" address [ street 
"Sunnylane" number "44" ] ]

Other examples:
<tag></tag> = tag [ "" ]
<tag>content</tag> = tag "content"
or tag [ "content" ]
Both are valid.
Correction!
This XML example:

<person alive="yes"><name>Mr. Smith</name><male/><address><street>Sunnylane</street><number>44</number></address></person>
Terry
25-Jan-2005
[63x2]
I like this.. 
°Mr. Smith° (main °7°) has the following..
 
	°Class?° °Person°
	°Alive Dead Status° "Alive"
	°Address 1° "44"
	°Address 2° °Sunnylane°
Notice that °Sunnylane° and °Person° are themselves °7°s?  This means 
that more information is available regarding them.. ie:

°Sunnylane: last time paved?° 
or 
°Sunnylane: set last time paved -=24-Oct-2001=-°


Because °Mr. Smith° is a °Person°, we could make a query like.. °Mr. 
Smith: requires food to survive?°  and have the system respond "Yes."
Geomol
25-Jan-2005
[65]
:)
Andrew
25-Jan-2005
[66x4]
Geomol, you might want to look at my ML dialect which has something 
very similar to what you're doing. ML is my Rebol dialect for writing 
XML.
In ML
In ML
/tag   ->     <tag/>
tag []    ->   <tag> (stuff in block) </tag>

tag/attribute value []    ->   <tag attribute="value"> (stuff in 
block) </tag>

<tag attribute="value"> []   ->   <tag attribute="value"> (stuff 
in block) </tag>
And it's all in one function.
Ladislav
2-Nov-2005
[70x5]
An "Internal dialecting" discussion. Currently REDUCE has got a REDUCE/ONLY 
option to specify, which words are *not* evaluated
I, OTOH, found an "opposite" approach specifying which words *are* 
evaluated very fruitful.
Examples are my BUILD dialect:
build/with [let's see what] build/with [what: [the rise of the (y)]] 
[
        y: 'sun
    ] ; == [let's see the rise of the (sun)]
or my SUBSTITUTE dialect:
JaimeVargas
2-Nov-2005
[75]
Do you have an example where reduce/only works. I only get errors.
Ladislav
2-Nov-2005
[76x2]
tests: substitute [
		generate-test [
			set variable value
			eq variable 1
		] [value] [1 2]
		return "OK"
		label fail
		do discard [print ["test:" mold testing "failed"] halt]
	] [generate-test]
Reduce/only example:
Volker
2-Nov-2005
[78]
example:
!> reduce/only[green blue][green]
== [green 0.0.255]
Ladislav
2-Nov-2005
[79]
>> reduce/only [a b c d] [b c d]
== [1 b c d]
Volker
2-Nov-2005
[80]
Maybe we need both reduce? AFAIK currently it is to have a reduce 
which allows keywords.
JaimeVargas
2-Nov-2005
[81]
Ah. Interesting. I think I needed this in the past I didn't know 
it existed.
Volker
2-Nov-2005
[82]
Good idea IMHO. Sadly i managed to crash it in my first try.
JaimeVargas
2-Nov-2005
[83]
I wish build was part of rebol. I find it a lot easier to use than 
compose. Only that slower.
Sunanda
21-Mar-2006
[84]
Bill Gates says "We need dialects"
http://microformats.org

(Actually he said "microformats" -- but I can't see any real difference 
in intent)
DideC
22-Mar-2006
[85]
Hum, not sure it's dialect equivalent. It looks like some "XML samples" 
to replace existing text format (ie iCal => hCalendar)
Maxim
22-Mar-2006
[86]
IMO nothing to do with dialect... AFAICT they are simply structured 
xml definitions...
Allen
22-Mar-2006
[87]
vCard --> iCard --> hCard  ... plenty of alphabet to go for future 
formats ;-)
Maxim
22-Mar-2006
[88]
just keep "R"  for us... we should patent the letter "R"   ;-)
Allen
22-Mar-2006
[89]
Well nothing stopping us from doing the same thing. Just do a like 
for like conversion as they did, but do it into rebol format instead 
of xml or xhtml
Gregg
24-Mar-2006
[90]
Visual Studio is getting DSL support, along the lines of what JetBrains 
has done I think. There's a team blogging about it inside MS, so 
I think Bill and Co. *do* think we need them (they're just doing 
it wrong ;-).
Thør
2-Apr-2006
[91]
initial sync...
Thør
26-May-2006
[92]
.
btiffin
15-Sep-2006
[93]
Requesting Opinions.  Being a crusty old forther, I really really 
miss the immersive nature of the block editor environment.  Coding 
in forth meant never leaving forth.  Editor, debugger, disk drivers 
etc... all forth commands.  No need to ever have the brain exit forth 
mode.  Now that Rebol is my language of the future, I kinda pine 
for the past.  The wonder and beauty of Rebol keeps being interrupted 
by decisions on what to use to edit that last little bit of script. 
 Notepad, Crimson Editor, Rebol editor? A small annoyance but it 
still disrupts the brain from getting to streaming mode.  So now 
to the question.  My first crack at a forth block editor dialect 
failed miserably.  Dialects need to be LOADable for parse to function. 
 Editing source code makes for unloadable situations.  Do I just 
give up on it and learn to live in the third millenium?  Write a 
utility that doesn't use dialects (which seems to unRebol the solution)? 
 I thought I'd ask you guys, just in case there is a light shining 
in front of me that I can't see.  Thanks in advance.
Graham
15-Sep-2006
[94]
forth editors used to access the hard drive sectors directly.  You 
want to do that?
btiffin
15-Sep-2006
[95]
Not really, just emulate the immersiveness.  I dealt with 16 lines 
of 64 characters for so many years that my little utility (in menta-space) 
uses a 32 by 80 character screen but all the output is normal text 
(with those confounded carriage returns).  We used shadows blocks 
extensively and I got so used to the technical docs being single 
letter command away...Just pineing.  Aside from that, is there a 
way to feed the string  $1,000,000  into block parsing?
Graham
15-Sep-2006
[96x2]
block parsing ...
some tricky things as it tries to identify datatypes
btiffin
15-Sep-2006
[98]
yeah exactly.  The unRebol way is to just string parse and then take 
the first token as a command...seems unworthy.  But I am willing 
to put up with a mirage for that immersive looky feely.
Anton
15-Sep-2006
[99]
Well, I've never gone Forth, and I'm not sure what a block editor 
is, but maybe you can benefit from some console commands. I almost 
always use Crimson Editor. I have an EDIT command which launches 
Crimson Editor, and I navigate the filesystem in the rebol console 
using dir-utils.r, which supplies unix-like filesystem commands; 
CD, LS, MV etc.
http://anton.wildit.net.au/rebol/os/windows/edit.r
http://anton.wildit.net.au/rebol/library/dir-utils.r
btiffin
15-Sep-2006
[100]
The Ctrl-E execute trick in Crimson is close but it is still a mental 
context switch.  Editor -> Rebol -> editor -> etc...  My old mantra 
was "Compile Link Go...Away, Go Go Go is much better"