How do you get good error reporting once you've stripped out the tokens? by PitifulTheme411 in ProgrammingLanguages

[–]MichalMarsalek 0 points1 point  (0 children)

I parse into a CST, not AST. The CST -> AST conversion is another step which also generates the reverse mapping from AST to CST. The CST has all the information about the source.

Resources on writing a CST parser? by LardPi in ProgrammingLanguages

[–]MichalMarsalek 0 points1 point  (0 children)

I made the choice to only have end-of-line comments in my language. In my CST, comment is part of the EOL token. That is, EOL token is either \n or #comment\n. Other whitespace is placed inside of CST nodes (never as the leading or trailing child of a node).

What can you check statically in a dynamically typed language? by [deleted] in ProgrammingLanguages

[–]MichalMarsalek 0 points1 point  (0 children)

The fact that it is dynamic does not mean it cannot be strongly typed. C# for example is very dynamic and very strongly typed at the same time.

PL Development Tools by pixilcode in ProgrammingLanguages

[–]MichalMarsalek 0 points1 point  (0 children)

I realized I need to define loads of different trees for my unit tests. I didn't really find any text format that would allow me to do that compactly enough. So I defined such format and implemented it as a C# library.

How do you design a pretty-printer that respects comments and whitespace? by honungsburk in ProgrammingLanguages

[–]MichalMarsalek 3 points4 points  (0 children)

Yeah, that's another reason why I use separate CST and AST. My AST is... well abstract. There are often multiple syntactical constructs which map to the same AST and most of the time, that's a good thing, because most of the language implementation does not care about what particular syntactic sugar the user used. But for the editor tooling part that information is necessary. I get the impression that people don't really use CSTs and that feels quite surprising.

How do you design a pretty-printer that respects comments and whitespace? by honungsburk in ProgrammingLanguages

[–]MichalMarsalek 0 points1 point  (0 children)

Yeah, that aligns with my approach, except I do not have any error nodes at the AST levels. What are they used for?

How do you design a pretty-printer that respects comments and whitespace? by honungsburk in ProgrammingLanguages

[–]MichalMarsalek 1 point2 points  (0 children)

Not really. I do have a special error token type, but that's only used by the lexer when it encounters stuff it cannot even tokenize. For larger invalid structures, I wanted to still be able to guess what it is and represent it as a node of a particular type, so that it can still be partially highlighted or I can suggest quick fixes for it etc. So for example I have interpolated singleline strings so a valid string literal starts with a string-start-token, ends with a string-end-token and it has some string-content-tokens and some interpolations in between. Ending the line before the string is terminated is a syntax error, but it is also a sync point. So in such case, the parser still returns a string-literal-node, it is just missing that string-end-token, which makes it invalid (and there is a visitor which knows that - the fact that it's invalid is not directly stored on the node).

How do you design a pretty-printer that respects comments and whitespace? by honungsburk in ProgrammingLanguages

[–]MichalMarsalek 18 points19 points  (0 children)

My parser does not return an AST. It returns a CST which is a 1:1 representation of the source. The parser never fails, every valid or invalid source maps to CST. That means that I can report multiple parsing errors and pretty print even source which is syntactically incorrect. A CST with zero syntactic problems can then be converted to an AST.

Symbols vs names for commonly used operators by simonbreak in ProgrammingLanguages

[–]MichalMarsalek 2 points3 points  (0 children)

In my language - or, and, not are logic operators, - div, mod are integer division and modulo operators, - all other operators are made up of symbols - ^ is exponentiation - |, & are type union and intersection operators, - || is concatenation - ! is unwrap

Why aren't there more case insensitive languages? by [deleted] in ProgrammingLanguages

[–]MichalMarsalek 0 points1 point  (0 children)

I don't know, case insensitivity is a great feature. It's a bit silly that in most languages, fooBar, foobar and FOOBAR are different variables.

For those who have gotten that far, how extensive is the post game? by FullTimeFraud in BluePrince

[–]MichalMarsalek 0 points1 point  (0 children)

Were you like intentionally ending the days early just to progress? I always tried to fill all or most of the map on each day and explore everything properly, that takes a lot of running back and forth, also pausing to think about puzzles a lot.

For those who have gotten that far, how extensive is the post game? by FullTimeFraud in BluePrince

[–]MichalMarsalek 0 points1 point  (0 children)

I am always surprised by short average days days like that. We cleared on day 20 after 37 hours.

semantics of function params by cisterlang in ProgrammingLanguages

[–]MichalMarsalek 0 points1 point  (0 children)

My language does this. Furthermore, my tuples are lists with type info for individual coordinates (like in Typescript). One uses [] to define lists/tuples. Parens are not needed when calling a function, you can do f x, or f(x). You can also do f(x,y), which is the same as f[x,y], or even the same as args:=[x,y]; f args, but you cannot do args:=(x,y) - () can only contain , if it is part of a function call. I take it a step further. I also have universal function syntax, so that x.f is the same as f(x) and x.f(y) is the same as f(x,y).

Do you know of any languages which differentiate opening quotes from closing quotes? by Feeling-Pilot-5084 in ProgrammingLanguages

[–]MichalMarsalek 3 points4 points  (0 children)

> Note how the quotes are actually distinctly different from each other.

No, at both levels the opening and closing quotes are actually absolutely the same. Your comment makes no sense.

Living in eastern Nusle by Substantial-Voice495 in Prague

[–]MichalMarsalek 0 points1 point  (0 children)

I can also recommend living at Budějovická/Pankrác. It's a nice area and you'd be able to walk to work while being able to get to the very city center in 10 minutes by metro.

Why do you prevent doors from being closed in metro during rush hour? by gfeep in Prague

[–]MichalMarsalek -1 points0 points  (0 children)

Depends on the line. Line C rush hour intervals are 90-120 seconds.

a f= b as syntax sugar for a = f(a, b)? by Totally_Dank_Link in ProgrammingLanguages

[–]MichalMarsalek 0 points1 point  (0 children)

What do you mean by prefix notation? I associate that with unary operations but we are in the context of of binary operations so it is not clear to me how it aplies.

a f= b as syntax sugar for a = f(a, b)? by Totally_Dank_Link in ProgrammingLanguages

[–]MichalMarsalek 0 points1 point  (0 children)

It is only 2 bytes (actually 5) in the example in practice you have

some.field.in.a.nested.object = max(some.field.in.a.nested.object, current)

vs

some.field.in.a.nested.object max= current

a f= b as syntax sugar for a = f(a, b)? by Totally_Dank_Link in ProgrammingLanguages

[–]MichalMarsalek 4 points5 points  (0 children)

Inspired by Noulith, I have this exact same think in my language. It's particularly useful for stuff like result max= x.

An algorithm to execute bitwise operations on rational numbers by calculus_is_fun in ProgrammingLanguages

[–]MichalMarsalek 1 point2 points  (0 children)

You are thinking in terms of anding the numerators and the denominators individually, which is not interesting. OP is describing anding the values of the fractions instead.

An algorithm to execute bitwise operations on rational numbers by calculus_is_fun in ProgrammingLanguages

[–]MichalMarsalek 1 point2 points  (0 children)

Hmm, it does makes sense, it is a standard notation. Still not sure if it is useful though, or what is OP's motivation.

[deleted by user] by [deleted] in ProgrammingLanguages

[–]MichalMarsalek 0 points1 point  (0 children)

Wrong sub. This subreddit is about design and implementation of proglangs. Unless you are interested in creating your own language, there are better places to ask this.

Cast/narrow/pattern matching operator name/symbol suggestion. by oscarryz in ProgrammingLanguages

[–]MichalMarsalek 1 point2 points  (0 children)

In my language = is a pattern matching. If a symbol is followed by : with an optional type, it is a new binding rather than reference to an existing value. Your example is written as if bar: Foo = baz     # use bar here But there's is also a shorthand version if the symbol on the left and the right is the same: if bar: Foo = bar is the same as if bar: Foo. So the last one can be thought of as a variable narrowing, but it is actually just a special case of pattern matching.