0

Are there any parser generators (compiler-compilers) that support varying keywords and operators?

My language has customisable keywords and operators (can have multiple symbols and have letters in them). I bypassed this issue before by mapping special symbols to operators and keywords and then using JFlex. Now, as syntax highlighting issue was brought up (we are using RSyntaxPane for that), this simply doesn't work.

EDIT: By the way, I only need the lexer part.

Also, some examples:

In the Russian layout, the curly brackets are missing. In the Russian translation:

{ = ?\
} = ?/

The keywords can also be localised, e.g. "function" is "функция" in the Russian translation.

nickguletskii
  • 292
  • 4
  • 9
  • So you want the parser to behave differently without regenerating it or the grammar? I highly doubt that's possible. Depending on your needs you may be able to create an operator-to-method mapping like Scala does, but even then the operators would have to be preset. I think that the idea of different keywords in the same language is a bit weird and dangerous, what do you need it for? – Viruzzo Jan 10 '12 at 15:47
  • So you want a lexer that can respond to operator/keyword declarations in the source code it processes? –  Jan 10 '12 at 15:47
  • @Viruzzo Grammatica works, but it doesn't return tokens correctly(it uses lines and columns, I need just the raw start position and end position). The customisable keywords and operators are required because we are working on something that needs to be multi-lingual. – nickguletskii Jan 10 '12 at 15:49
  • @delnan No, they are loaded from a language file. – nickguletskii Jan 10 '12 at 15:53
  • @BartKiers function: In English: `function`, in Russian: `функция`, in French: `fonction`, etc... Operators: we would keep operators standard, but some keyboard layouts are missing some characters. e.g. on the Russian layout, there are no brackets. We replaced them with such constructions: `?\ ` and `?/` And no, I only need a lexer. Thanks! – nickguletskii Jan 10 '12 at 16:03
  • Since you only need a lexer (and you apparently can't use JFlex any more?), I'd consider creating a custom lexer containing a number of regexes that you'd chain together using `|`'s (OR's). You could use an existing parser generator like ANTLR for it, but it'd get rather clunky. – Bart Kiers Jan 10 '12 at 18:59
  • @BartKiers Probably the way to go :/ – nickguletskii Jan 10 '12 at 19:47

0 Answers0