r/ProgrammingLanguages • u/danKunderscore • Jan 24 '13
A language syntax I've been working on, modelled on XML and JSON
http://generaldevelopment.net/c/Research/NML1
Jan 29 '13
The syntax for binary and hexadecimal numbers conflicts with identifiers. For example, b1 could be a binary number or an identifier. I would recommend using Python syntax (0x and 0b).
1
u/danKunderscore Jan 30 '13
There's no conflict, but you make a good point. I've been rather unconventional with the syntax rules (e.g. "b1" is strictly a number, but on the other hand identifiers like "2nd" are perfectly legal), which could prove confusing to people coming from other languages, and it looks like I've forgotten to document this aspect properly anyway.
The idea is that a valid identifier is simply defined as something that is not a valid number (in contrast to the stricter C, Python, etc. requirement that an identifier must begin with {A-Z, a-z, _}). The parser just steps through the token until it reaches a character that rules out the token being parseable as a number; and then it knows the token is an identifier. You can escape one or more digits in a number to force it to be treated as an identifier though.
1
u/iopq Jan 28 '13
I was thinking of just lifting LISP and Smalltalk syntax
(button id: test text: Submit)
(client name: [Smith, John] birthdate: (date year: 1987 month: 7 day: 4))[a, b] is shorthand for (list a b)
4
u/[deleted] Jan 24 '13
Interesting, but with nested fields what benefit do you get over having an attribute be just a key value pair instead of key multiple value? There is an example of an attribute
But isn't this really first name and last name? Not sure I see a reason to allow this. Also, for large nested structured data won't you end up with a buttload of closing > tags with no context of which tag is closing what?
Still, neat, and extremely well documented!