That looks like BASIC.
I'm willing to write a BBCode parser as long as someone comes up with good syntax.
Name:
Anonymous2007-09-11 23:05 ID:bSo/zKt7
Maybe use an ENTERPRISE TEXT FORMATING ALGORITHM to show off your true understanding of BBCode.
Name:
Anonymous2007-09-11 23:43 ID:0KewA/Uc
How about this
To define a tag you write [:hello].
Example
[:expert][b][u][o][][/o][/u][/b][/:]
[expert]I AM AN EXPERT PROGRAMMER[/expert]
You can explicity specify how many arguments a bbcode tag can have
[0:2br][br][br][/:]
So [2br] => [br][br]
[2br]wtf[/2br] produces an error by the parser/compiler.
For this to work, we need a good standard tag library.
>>4
Oh yeah, and [] is the array of arguments, while [n] is that certain argument.
To call a function you simply [function_name] not that [call="function_name"] crap
Name:
Anonymous2007-09-11 23:46 ID:b3hp8tZN
[bbcode]
[int=a][/int]
[for=a, 1 to 100]
[print]a[/print]
[if=0]mod a 3[append]"fizz"[/append][/if]
[if=0]mod a 5[append]"buzz"[/append][/if]
[+=a]1[/+]
[/for step=1]
[for=1:100; a, b]
[print=a, b][/print]
[if=0; a]mod a 3 this is comment[print="fizz"][/print][/if]
[if=0; a]mod a 5 this is comment[print="buzz"][/print][/if]
[op=add; a 1][/op]
[/for]
Proposed syntax:
[cοde]
for i in range(1, 10):
print 'OMG BBCode!!!'
[/cοde]
Name:
Anonymous2007-09-12 1:21 ID:/VaIOmVO
screw you people, i've already started defining a syntax, and it is superior to yours.
e.g:
[BBCPL]
[DEF = "EXPERT"][b][o][u]^[/u][/o][/b][/DEF]
[DEF = "LINK"]<a href ="$1">^</a>
[FOR = " [INT = "i"]o[/INT]:[i]<5:[+[i],1]]
[LOL]
[/FOR]
[/BBCPL]
>>20
That's much better than those steaming piles of crap suggested by the imperative fuckwits, but still that's only lisp with parentheses replaced with square braces. That doesn't make it any more interesting.
>>22
Not at all. Note, for example, how he cleverly disposed of explicit argument declaration, and instead went for simple automatic argument assignment to a b c ...
>>20
Pretty good, but we should take advantage of the ability to name or not name blocks as we wish.
[define]
add-pair
[+]a b[/+]
[/define]
# [add-pair]1 5[/add-pair]6
# [add-pair]1 5 [atom name=lol]``code''[/atom][/add-pair]6
Numbers and strings written alone are shorthand for [atom]value[/atom]. If they are given as parameters to a function, they get the names a, b, c, etc. The symbol "args" is a list of all unnamed arguments. When a function foo (e.g. [foo]) is followed by one or more parameters of the form n=x (e.g. [foo n=x]), those symbols are bound to those values in the environment that function is evaluated in. They go out of scope when it ends. However, a function may also return a named value which enters the environment "the next level up". So, in the last example, [add-pair] is evaluated, then its arguments 1 and 5 are evaluated and assigned the symbols a and b, respectively. Then the next argument is evaluated. Atom's environment contains the binding 'name = "lol"', and creates the binding 'lol = 7' in its caller's environment. If we were to add the code [when][boundp]lol[/][return]``idk, 60 million lol''[/return][/when] to add-pair, then the second example would return the string ``idk, 60 milion lol'' in the second example, rather then the correct answer of 6. Also note that [/] may be used to close a block if your typing finger is tired, and that quotes are written ``'' for enterprise-grade nestability.
>>38
It doesn't follow the semantics. In scheme, you do (foo a b c) where in BBCode you need to write [foo]a b c[/foo] to keep it consistent with how the pre-existing tags work.
Name:
Anonymous2007-09-13 11:50 ID:Lxi/dWxS
>>39
I propose that anything at top level that is not a function call should be treated as literal (and HTML-escaped). This way: [b]a b c[/b]
would be treated as (display "<B>") (display (html-escape "a b c")) (display "</B>") yet [foo a b c]
would be treated as (foo a b c).
The problem with [foo]a b c[/foo] is how to treat what's outside the square brackets. Is it three symbols? A string? Is whitespace significant? Etc. We'd have to treat everything outside [] as a whitespace-sensitive string, and all functions would have to be functions of one string argument returning one string. And this means we can't return functions. And this means we can't fix the one arg limit as you would in Lambda Calculus. Unless you allow nesting [], which would be piss ugly... (add 1 2) would become: [[add]1[/add]]2[/[add]1[/add]]
All of this means we'd be getting something worse than Tcl. So I propose a Lisp, with the toplevel exception I described.