World: r3wp
[Dialects] Questions about how to create dialects
older newer | first last |
btiffin 21-Sep-2007 [259] | Read this today, re programming language choice; http://www.paulgraham.com/icad.html Down near the bottom is the Appendix: Power. and leads to http://www.paulgraham.com/accgen.html I can read the languages he uses as examples, but only a few of them come close to the readability of foo: func [n] [func [i] [n: n + i]] or am I just too sucked into REBOL/Think? It's too bad the page has extra space around the brackets, as at a quick glance REBOL would be in the top four shortest. It's as quick grokable (meaning a quick glance implies a function returning a function that accumulates) as Dylan, LUA, Javascript and NewtonScript. And who uses Javascript? :) |
Ladislav 23-Sep-2007 [260x4] | hmm, but foo: func [n] [func [i] [n: n + i]] is wrong |
foo: closure [n] [func [i] [n: n + i]] is necessary for this to work reliably | |
example: f1: foo 1 f2: foo 2 f1 1 should yield 2, not 3! | |
another reliable implementation not using closure: foo: func [n] [use [m] [m: n func [i] [m: m + i]]] | |
btiffin 23-Sep-2007 [264] | Learn something new here everyday. :) |
RobertS 23-Sep-2007 [265] | In this context I am not going to offer the Curl examples for DSL and pass-the-proc except to say that ... no , I won't say that either ;-) |
Terry 24-Sep-2007 [266] | But Gregg, the reference was towards a "language that combines vocabulary and grammar"... sounds more like "Energy equals mass times the speed of light squared", rather than E = MC2 |
Gregg 24-Sep-2007 [267] | I understand; my point was that mathematics, as a foundation, allows you to express things in a domain that Basque, historically, does not. A DSL doesn't *have* to be an extension or outgrowth of an existing language, but that can often help. In order for tha that to work, you need to choose a base language that suits your needs. |
Brock 13-Jun-2008 [268] | Has anyone written a dialect to capture live sports action? Here are some examples of the types of items needed to be captured... Volleyball... http://www.wnmu.edu/athletic/stats/07vb/29wnmu.htm#GAME.PLY Hockey... http://www.nhl.com/scores/htmlreports/20072008/PL030416.HTM Soccer... http://www.uefa.com/competitions/ucl/fixturesresults/round=15109/match=301604/report=mbm.html |
Henrik 13-Jun-2008 [269] | what would the dialect do? |
Brock 13-Jun-2008 [270] | What I am going to attempt is a dialect that will respond to single key-strokes to tell the story of a match and at the same time capture the statics for the live game. Hopefully the end result will lead to many different tools based on this data such as statistics visualizations in the form of data summaries/reports and charts. |
Henrik 13-Jun-2008 [271] | It looks pretty parse friendly. |
Brock 13-Jun-2008 [272x4] | The sport I am most interested in doing this for is Volleyball as I have experience coaching this sport. |
Yes, I was thinking parse would likely be the way to go. | |
Each skill would be given a character on the keyboard and would expect it to be followed by a player number and the level of success of the player attempting the skill. | |
As I haven't worked much with Dialects I wasn't terribly sure how to start, so was looking for some dialect examples that might influence my starting point. | |
Henrik 13-Jun-2008 [276] | well, first I'd build the skeleton for the dialect for parsing a single line. then I might add some actions to it and then expand it to handle multiple lines. |
Brock 13-Jun-2008 [277x3] | The first line of the volleyball page http://www.wnmu.edu/athletic/stats/07vb/29wnmu.htm#GAME.PLY , the line starting 1-0, _might_ be represented by the following keystrokes... s43a23b50 So, s = set attempt, 4 = player Cola Svec, 3 = set attempt level 3 - perfect set a = attack attempt, 2 = player Jeri Walkowiak, 3 = attack attempt level 3 - kill b = block attempt, 5 = player Jessica Lindgren, 0 = block attempt level 0 - error |
I might need to add a team designator like H = Home, V = visitor as it could be complicated to catch live play and may need to establish which team inorder to correctly identify a player. I may also need to use a separator between each keystroke if I want to identify the player by jersey number. | |
I will need to start playing with this to see if I can come up with something and then maybe get some feedback on my attempts. I don't know when I would get to this but thought I'd through it out there. | |
BrianH 13-Jun-2008 [280] | If this is typing in real time, space would be the best seperator, |
eFishAnt 23-Jun-2008 [281x4] | anyone know how to parse this: |
{<table><table></table><tr></tr></table>} | |
It is a table with an empty table inside, and also a Table-Cell | |
for some reason, using recursion...I just can't seem to put my finger on the right combo. | |
Chris 23-Jun-2008 [285] | What's the goal? |
eFishAnt 23-Jun-2008 [286x5] | parse rules that will give a true if parse/all {<table><table></table><tr></tr></table>} RULES |
(using recursion) | |
like Tables: [Table Tables | Table] | |
Table: ["<table>" Content "</table>"] | |
...and so forth. | |
Chris 23-Jun-2008 [291] | rule: use [table row][ row: [<tr> </tr>] table: [<table> any [table | row] </table>] [table] ] |
eFishAnt 23-Jun-2008 [292] | As Robert de Niro said in one of my favorite movies of all time, "Analyze This" "...hey, you...you're good!" |
Chris 4-Aug-2008 [293x3] | rfc: I have a (not so) little function that attempts to match a block of values to a given specification. Example: >> probe match [%image.png :red 300x100 /old][ [ file: file! | url! [ size: opt pair! [ attributes: any get-word! | refinement! [ ] make object! [ file: %image.png size: 300x100 attributes: [:red /old] ] There's not much to the rules, they are -- one (default), opt (zero or one), any (zero or many), some (many). If they don't match, they return an error. Any suggestions? Optimizations? http://www.ross-gill.com/r/match.r |
Ways of making it smaller??? | |
One of the desired effects is precedence, for example: match [http://rebol.com%image.png][ link: file! | url! image: file! | url! ] Returns: [link: http://rebol.comimage: %image.png] | |
Gabriele 4-Aug-2008 [296] | I do something like that, but text based, in QML. not sure if it can be of any help. |
Alan 14-Sep-2008 [297] | . |
Robert 25-Feb-2009 [298x4] | What's the best approach to support normal Rebol things like FOREACH, IF, ANY, ALL and set-words, get-words within a dialect? I don't want to write Rebol parse rules for this. |
Example: parse XYZ mydialect XYZ: [ repeat x 1 14 [ a: get-point x 7 set-point 7 x (a * 2) ] ] ] | |
get-point and set-point are the dialect things. The rest should be normal rebol. | |
Is there a best practice how to get Rebol control structure support into dialects? | |
Janko 25-Feb-2009 [302] | but isn't this just a regular rebol code block then .. a: get-point x 7 and set-point looks like a normal rebol func too? |
Robert 25-Feb-2009 [303] | Just assume that get-point and set-point is done via a dialect. |
Janko 25-Feb-2009 [304] | aha, I would also like to know if that is possible .. I still haven't figured out how they do ( some code ) in parse |
Gregg 25-Feb-2009 [305x2] | Use Gab's compile-rules module. |
Gab = Gabriele | |
BrianH 25-Feb-2009 [307x2] | Robert, if you don't want to use parse rules you might try DO/next. Don't use DO/next (or Gabriele's compile-rules) if your dialect data can come from an untrusted source - use parse rules and dialect operations that call the REBOL functions if necessary. |
But *only* the REBOL functions that you want to support and can do so safely. | |
older newer | first last |