Started writing a parser for moonscript. Because I want to do my own syntax highlighting and error support.

I'm sorry, but was this supposed to difficult? Every article I read claimed this was gonna be some impossible feat of herculean effort. I half dreaded it, the other half was kinda elated.

Only it didnt live up to the hype. The tokenizer is a glorified character stream. The lexer is little more than a tokenizer, and the "most complicated" bit is nothing but a fancy transformation of the token output into a tree.

I'm completely to new parsers proper and semantic checking and maybe that's why it seemed easy, but I dont see what all the forewarning in tutorials were ever about.

  • 4
    This is turning out be an enjoyable exercise to familiarize myself with the topic.

    I'm thinking I'll do a *small* language for processing data structures in complex ways. Like if I want to do a tree walking algo, I could have syntax that makes it easy to specify
    "Depth first on main nodes, breadth for branches n-deep, and then use xyz pattern to alternate, and repeat some specific set of microstrategies ad infinitum till the structure is processed." Like regular expressions, but instead data structures instead of strings. And instead of black magic, actually readable.

    And it could be used to do one-to-four liners that would otherwise take 20-40 lines in python or some incomprehensible list comprehension, or worse, a bunch of custom functions.

    I want to be able to restructure and transform data in complex ways, just by specifying arguments, with my eyes shut, instead of 500 loops, sub functions, and off by one errors rearing their heads.

    Less plumbing and more data processing.
  • 2
    @zlice moonscript because I need it for my script editor component.
    Moonscript is this nifty expansion of lua that makes some things about it same again.

    What are you using?
  • 1
    @zlice what's your language inspirations?

    Have you tried a parserless system?
    Familiar with the difference between PEG and older CFGs?) ? Because I wouldnt mind a quick rundown.
  • 2
    Right on! I know with absolute certainty that there are people that need to hear this. It’s not that complicated to write a language, in fact it’s much easier than debugging ridiculous spaghetti code that is littered with regex matching.
Add Comment