Replies: 5 comments 5 replies
-
Nice! I considered LISPy syntax and Python-like syntax for MarkovJunior but in the end I chose XML because it was good enough and I don't have to write/maintain a parser for it. |
Beta Was this translation helpful? Give feedback.
-
I might have gone ever so slightly overboard with this, and now it has expressions with unary and binary operators, which allows for an elegant and very generalisable way to describe e.g. convolution rules. At this point I suppose I should just accept that I'm designing a spinoff language that's very heavily based on MarkovJunior but with different semantics. Cave
|
Beta Was this translation helpful? Give feedback.
-
My 2 cents about the topic. I think the most agnostic and versatile solution would be to adjust the objects/structs to be readily serializable by out of the box solutions like xmlserializer and newtonsoft.json. For the most part it would only require to decorate classes and properties with DataContract and DataMember attributes. This would provide a language agnostic format that can be easily accessed from almost anywhere, a very significant load time boost and would eliminate the need for maintaining a parser. XML is verbose but it would allow us to define a XSD so smart editors can catch mistakes (and suggest/autocomplete). Alternatively, JSON Schema might be a less verbose solution (http://json-schema.org) (not sure about editor support). Personally, I rather have a very verbose syntax that can warm me about errors beforehand than a nice and fast to write one that has the potential to waste a ton of my time later trying to catch a silly error. |
Beta Was this translation helpful? Give feedback.
-
Incidentally, @mxgmn - the working name for my language is MJr, which is (obviously) an abbreviation of MarkovJunior. If you think this is too similar and people could confuse them for the same project, let me know and I'll think of a different name. |
Beta Was this translation helpful? Give feedback.
-
My 2cents on the topic is pretty similar to @TieSKey's XML is good enough for this project since XML is tree-based just like MJ. From my experience with this project, my main concern with the current XML syntax is just it's too "abstract" when it comes to defining input/output patterns. My brain can only remember so many letters and what I'm using them for and what pixel/voxel they actually represent; not mentioning a large pattern would probably need to be imported from a png/vox file which adds another layer of complexity to the creation of an MJ model. That's why I think a more visual approach would truly boost productivity instead of inventing another syntax, which is why I want to work on a visual editor for my web version when I have time. Another thing I would love to make if I could work full-time on this project would be to make an interpreter & compiler in C/C++ that can run directly or generate executable/static lib/shared lib from an MJ model, making it a true MJ program and it would get a huge performance gain since pattern matching code can be inlined and unrolled in contrast to current slow nested-loop generic implementation. |
Beta Was this translation helpful? Give feedback.
-
I started thinking about a simpler syntax for MarkovJunior programs, because at least personally I think XML is a bit tedious to write, and a parser based on XML will silently ignore any tags or attributes it doesn't look for, which may make it harder to notice mistakes (particularly when an attribute is added to the wrong tag, or misspelled). And because designing languages is fun.
Comments and suggestions from everyone interested in MarkovJunior are appreciated! I'll illustrate the syntax with examples below, translated from the example models. I'm doing this for my own project mainly, but @mxgmn if this is something you're interested in, I'd be happy to write a parser for the official MarkovJunior project in C# once this syntax is complete and set in stone. (No worries if you don't think this would be a good idea.)
Backtracker
BacktrackerCycle
BasicBrickWall
BasicDijkstraDungeon
BasicSnake
A few notes on some of the design decisions:
{}
for blocks if arguments likelimit=2
were written without delimiters, or with()
delimiters (although that would make tokenization harder because it conflicts with patterns); another option would be to use keywords likeendall
,endmarkov
etc., though I'm not a fan of this.sequence:
, though this doesn't occur in the examples above..
instead of*
for wildcards; this is consistent with regexes, a bit visually clearer IMO, a bit easier to type on many keyboards, and avoids having/*
or*/
occur inside patterns (which can be a pain when writing patterns inside strings in another language, where those delimit comments).once
is syntax sugar forone {limit=1}
.origin
a special pattern which matches at the centre of the grid, instead of a boolean flag. This means you can rewriteorigin
with any pattern (not just a colour in one cell), anywhere in the program. Semantically, anorigin -> ...
rule returns false if the output pattern is already present, so there is no infinite loop if it's used in amarkov
node. In principle, rules could allow other position-based input patterns (this would require some syntax for describing positions).I'm also writing a parser for this syntax, for my own project, and to make sure it works from an implementer's perspective. Including type definitions, it's currently at about 530 lines of TypeScript code, and can successfully parse all of the examples above. It would be good to get feedback about the syntax before doing much more work on it, though.
Beta Was this translation helpful? Give feedback.
All reactions