Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The BBCode programming language

Name: Anonymous 2007-07-18 6:39 ID:PTojbCHk

This is for real. I'm considering writing a BBCode programming language, intended for use in message boards. It'd be backwards-compatible with the current BBCode, but it'd allow you to write ad-hoc programs that generate your post.

Basically, it'd be a LISP, with these four properties beyond the usual:
- Only you configure the opening and closing parens, which you can set to [].
- In the top level, any sequence of characters that is outside of any application (outside []) is evaluated as string (preserving whitespace and everything), and returned as is, except <, > and & are converted to HTML entities.
- The resulting post is the concatenation of everything that's evaluated at top level, which means you get everything in the top level outside [] and every string any functions you called returned. (Other types functions may return are converted to their canonical representation.) Function results may safely return HTML; their <, > and & are not automatically converted to HTML entities.
- When you apply a non-applicable or non-existent symbol, you get a string which consists of [, the symbol, and ], so that unrecognized tags are printed as is (which is the current behaviour in BBCode).

For example, this would define the [ b ] and [ /b ] for bold, assuming we're using { and } for open/close parens (used {} so that BBCode doesn't fuck it up)

{define {b} "<b>"}
{define {/b} "</b>"}


What do you think?

Name: Anonymous 2007-07-18 7:57 ID:Heaven

>>1
For example, this would define the [ b ] and [ /b ] for bold,
fail bbcoder,
if you want it to appear as is, you use \ to escape
example
[b]bold[/b]
;)

Name: Anonymous 2007-07-18 7:57 ID:3lOpgXZg

Show us a demo

Name: Anonymous 2007-07-18 8:04 ID:Heaven

>>3
true, show us a demo, that you actually put some effort into it and you don't expect everything from us.

Name: Anonymous 2007-07-18 8:46 ID:Heaven

>>1
[define [b] "<b>"]
[define [/b] "</b>"]

Name: Anonymous 2007-07-18 9:19 ID:n7RC+8I2

(define [b] "<b>")

Name: Anonymous 2007-07-18 9:22 ID:PTojbCHk

Testing
[b]type a[/b]
[\b]type b[\/b]

Name: Anonymous 2007-07-18 9:25 ID:ZyzraFMM

[b]bold[/b]

Name: Anonymous 2007-07-18 9:34 ID:PTojbCHk

Ok, so >>4 asked for an example and here's one that will make a post like:

>>1
NO U

>>2
NO U

...

for all previous posts, assuming we can get the current post number with (meta 'current-post).


Hello everybody,

\[define no-u \[lambda \[x] \[limit]
    "NO U at posters x, x + 1, ... limit - 1"
    \[print >>x EOL \[b] "NO U" \[/b] EOL EOL]
    ;Note: >>x would be a macro that works at top level too
    \[if \[< x limit]
        \[no-u \[+ x 1] limit]]]]
\[no-u 1 \[meta 'current-post]]

Name: Anonymous 2007-07-18 9:35 ID:PTojbCHk

>>9
Failed :( Well, remove all those backslashes and you'll see what I mean.

Name: Anonymous 2007-07-18 12:34 ID:Heaven

[
\]
\/
[b\]
[b\]
[b]

Name: Anonymous 2007-07-18 12:35 ID:Heaven

\[
\]
\/
\[b\]
[b\]
\[b]

Name: Anonymous 2007-07-18 12:38 ID:Heaven

[define]
  [name]b[/name]
  [lambda]
    [args]arguments[/args]
    [content]<b>[concat][variable]arguments[/variable][/concat]</b>[/content]
  [/lambda]
[/define]

Name: Anonymous 2007-07-18 13:48 ID:ewMtRWnA

I liek the idea.  On what imageboard it will be based?

Name: Anonymous 2007-07-18 17:36 ID:qfDTgMyw

>>14
imageboard? you must mean textboard, there's no such thing as an imageboard.

but it'd obviously be based on shiichan, for it is the most enterprise quality board software available.

Name: Anonymous 2007-07-18 18:33 ID:dhjcCxRM

Actually, my reference implementation will be in Python. A Python module which you can call anytime, even in a subprocess so that you render the final text to be stored in the DB (for non-edit boards such as Shiichan). I could port it to PHP afterwards, depending on my time and interest.

Name: Anonymous 2007-07-18 18:57 ID:Heaven

Here's a serious question.
If it's Turing complete (and by which I don't mean Touring complete; that's implicitly true if it's based on BBCode), and it's interpreted server-side, how will you handle cases where a script hangs?

Any time you let people submit scripts to the server to run, you're just bending over and grabbing your ankles.

Name: Anonymous 2007-07-19 4:57 ID:5Z/iH/zm

>>17
LOL, just prove that the script doesn't hang.

Name: Anonymous 2007-07-19 5:20 ID:FiL56+Wj

>>17
I could limit the execution "amount" by allowing up to a number of calls to eval or apply. This number could be configurable, or dynamically decided based on server load. After reaching that limit, I'd exit all nested functions and append "***Killed with fire***" and return whatever output was already produced.

I'd also limit output to a configurable number of KBs, to avoid

[define [x] [display "SICP "] [x]]

Name: Anonymous 2007-07-19 5:28 ID:ZYN1gZjE

>>18
Solving the halting problem? In my bbcode interpreter?

Name: Anonymous 2007-07-19 5:30 ID:Heaven

>>19
Altering the operation of the server based on its load serves as an excellent indicator to a script kiddie that their DDoS is effective.

Name: Anonymous 2007-07-19 5:35 ID:KeG+Y2lQ

I recommend you compile it to client-side javascript.

Name: Anonymous 2007-07-20 4:39 ID:eEwRBm1h

>>21
So ping is

>>22
That's a great idea, I should do that

Name: Anonymous 2007-07-20 8:06 ID:Heaven

>>23
Ping can be disabled altogether.

Name: Anonymous 2007-07-30 15:19 ID:O/OhtPpR

Ok, I got myself to start writing the first BBCode implementation in Python. I'll go on vacation tomorrow so don't count on a release soon though. It's going to be a Lisp similar to Scheme, with the following features and differences:

- Customizable special characters, so it can work with [] instead of ()

- Anything at top level, except function calls, will be echoed verbatim (kind of like PHP...), so that nothing gets affected outside [] and you can post normally, no quotes required or anything.

- {} will be used for quoting strings in Perl's q{} fashion, which is far more comfortable to use than "".

- Of course, it'll have first-class functions, lexical nested scoping and tail call optimization. I already have a working prototype with these features, so count on them.

- You can call Python functions just like BBCode functions (out of those allowed in toplevel, which is going to be a Python module's namespace), and BBCode functions can be called from Python code just the same. You can even do things such as str.join to access Python's join method of the str class.

- You can have access to a BBCode function's source code and introspect its parameters as well.

- There's going to be a simple way of implementing (pure BBCode) lazy evaluation and macros, and they will be first-class macros which are little different from a function.

- Lists won't be conses, but Python lists. This means less efficient cdr, but more efficient anything else. There's going to be dictionaries.

- There's going to be syntax to index lists and dictionaries comfortably, so you can do (with Lisp characters): (display i[3]) or even (display i[(+ x 5)]). In BBCode mode, I swap [] and (). This would be the same as doing something like (display (method i __getattribute__ 3)), and method or meth will be used to call Python methods. The set special macro will support this syntax, too.

- The standard library will be much reduced and not always similar to Scheme, even in basic constructs. For example, I may not implement let but have you use define and set, as you would use = in Python, and I may borrow a lot from Python since Python objects can be seen and called as BBCode ones.

- I'm considering implementing classes, exceptions, continuations and modules, but that's certainly going far too beyond the scope of BBCode, so they won't be in the initial release.

- Finally, I'm implementing a special macro define-with-the-forced-indentation-of-code.
Just kidding.

What do you think?

Name: Anonymous 2007-07-30 15:22 ID:O/OhtPpR

Oh, and of course, the standard library will have something like:
[define [b] [display "<b>"]]
[define [/b] [display "</b>"]]

etc. so that it's backwards-compatible with existing BBCode.

Name: Anonymous 2007-07-30 15:27 ID:L7wiNCwD

stupid smug bbcode newbies.. wont you realise theres no point in reinventing the wheel, common bbcode is great theres nothing to fix.

Name: Anonymous 2007-07-30 15:28 ID:87Cv1RNs

- {} will be used for quoting strings in Perl's q{} fashion, which is far more comfortable to use than "".

Kill yourself

Name: Anonymous 2007-07-30 17:11 ID:O/OhtPpR

>>28
Lol. Seriously, how many times do you need "" and how cumbersome are they to escape (not to mention the quote hell that arises from escaping escaped strings and such ("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"...."), versus how many times do you need unmatched { or }? Besides, I'm still supporting "", I'm just providing {} as an additional means of quoting for sane people.

Name: Anonymous 2007-07-30 17:22 ID:87Cv1RNs

I don't use Perl, so I don't write ugly shit. Sorry.

Name: Anonymous 2008-03-04 7:31

how do i bbcode?

Name: Anonymous 2008-03-04 7:55

>>29
#define QUOTE "\""
#define ESCAPE "\\"

printf("you" QUOTE ESCAPE ESCAPE ESCAPE "FAGGOT" ESCAPE ESCAPE ESCAPE QUOTE "\n");

{} ? What if I want to print { or }? Yeah, I have to escape them.
great.

Name: Anonymous 2010-11-13 19:41

Name: Anonymous 2011-02-04 16:41

Name: Anonymous 2011-08-04 6:50

test
test

Name: Anonymous 2013-06-06 9:40

shit

Name: Anonymous 2013-06-06 9:40

shit hit  it

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List