Hi guys, I hope you're all right!
Today, I'll mix
Noisett (a string pattern matching network),
PL/S (a deliberately simple language), and
DSX (a sentence structure syntax) together.
Rationale: Noisett is cool, but it works on simple strings, where the structure of sentences is not explicit, which makes it too weak to rock. I wanna make it lift heavy weight now. The whole thing is supposed to run on NodeJS.
Let's start with Noisett. Noisett is a network of agents called Nuts. Each nut reacts to incoming messages by testing them against patterns, and reacting accordingly. Noisett syntax uses special characters instead of keywords. Since I'm going to need special characters for something else, I first have to flatten Noisett's syntax, to make it look like PL/S.
Here is Noisett2's instruction set:
* Wildcard
$1 Capture
@ Name of message sender
SHARE: send to followers
REPLY: send only to sender
IF: go on if message matches pattern
IFNOT: go on if message doesn't match pattern
IS: go on if pattern found in section
ISNOT: go on if pattern not found in section
SECTION: choose current section
APPEND: add to section
REPLACE: locate a target in current section
BY: replace target by something else
COPYALL: copy all matches from previous section to current section
COPY1ST: copy first match
COPYRND: copy one of matches
REMOVE: del from section
NUT: create or select nut
UPLOAD: as section (ok if new section)
DOWNLOAD: section from nut in current
ANYWAY: stop skipping commands
EXEC: execute this section or js file
ARGS: with this as message
Now, instead of:
[MAIN]
I'm * + * Noisett * > Received $2
We have:
[MAIN]
IF: I'm *
IF: * Noisett *
SHARE: Received $2
Good. Next step: we want to make the structure of sentences explicit, so we'll need DSX stuff.
DSX looks like:
I < need < ( [ your > clothes | your > boots ] =and= ( your > motorcycle ) )
Special characters < and > show subordination, and == characters show coordination. Parentheses group things.
We could turn this example into the following JSON:
[
{
"id": 1,
"content": "I",
"container": 0,
"main clauses": [],
"subordinate clauses": [2],
"coordinated by": [],
"coordinator of": []
}, {
"id": 2,
"content": "need",
"container": 0,
"main clauses": [1],
"subordinate clauses": [3],
"coordinated by": [],
"coordinator of": []
}, {
"id": 3,
"content": [4, 5, 6, 7],
"container": 0,
"main clauses": [2],
"subordinate clauses": [],
"coordinated by": [],
"coordinator of": []
}, {
"id": 4,
"content": "and",
"container": 3,
"main clauses": [],
"subordinate clauses": [],
"coordinated by": [],
"coordinator of": [5, 6, 7]
}, {
"id": 5,
"content": [8, 9],
"container": 3,
"main clauses": [],
"subordinate clauses": [],
"coordinated by": [4],
"coordinator of": []
}, {
"id": 6,
"content": [10, 11],
"container": 3,
"main clauses": [],
"subordinate clauses": [],
"coordinated by": [4],
"coordinator of": []
}, {
"id": 7,
"content": [12, 13],
"container": 3,
"main clauses": [],
"subordinate clauses": [],
"coordinated by": [4],
"coordinator of": []
}, {
"id": 8,
"content": "your",
"container": 5,
"main clauses": [9],
"subordinate clauses": [],
"coordinated by": [],
"coordinator of": []
}, {
"id": 9,
"content": "clothes",
"container": 5,
"main clauses": [],
"subordinate clauses": [8],
"coordinated by": [],
"coordinator of": []
}, {
"id": 10,
"content": "your",
"container": 6,
"main clauses": [11],
"subordinate clauses": [],
"coordinated by": [],
"coordinator of": []
}, {
"id": 11,
"content": "boots",
"container": 6,
"main clauses": [],
"subordinate clauses": [10],
"coordinated by": [],
"coordinator of": []
}, {
"id": 12,
"content": "your",
"container": 7,
"main clauses": [13],
"subordinate clauses": [],
"coordinated by": [],
"coordinator of": []
}, {
"id": 13,
"content": "motorcycle",
"container": 7,
"main clauses": [],
"subordinate clauses": [12],
"coordinated by": [],
"coordinator of": []
}
]
Using the following conventions:
id #
content +
container ^
main clauses <
subordinate clauses >
coordinated by %
coordinator of &
We can shrink this example to:
#1+I>2 #2+need<1>3 #3+4,5,6,7<2 #4+and^3&5,6,7 #5+8,9^3%4 #6+10,11^3%4 #7+12,13^3%4 #8+your^5<9 #9+clothes^5>8 #10+your^6<11 #11+boots^6>10 #12+your^7<13 #13+motorcycle^7>12
And then use this kind of things in a Noisett2 agent:
[MAIN]
IF: #1+I>2 #2+need<1>3 #3+*
SHARE: #1+@>2 #2+needs<1>3 #3+$1<2
Here, if NutX says "I < need < raincheck", agent will say "NutX < needs < raincheck".
The same could be written like this:
[MAIN]
IF: I < need < *
SHARE: @ < needs < $1
Lovely, isn't it?
EDIT:
Poll
[ ] It rocks!
[ ] It sucks!
[ ] You're insane!
EDIT: Inevitable typos + clear syntax