Recent

Author Topic: Synedit general question  (Read 4005 times)

cybermonkey342

  • New Member
  • *
  • Posts: 42
    • Home of EGSL interpreter
Synedit general question
« on: March 07, 2013, 10:31:02 pm »
Ok, I found in the deep of the internet the following line (must have been from the lazarus mailing list):
Quote
SynEdit is good enough and quite fast, i used it at some point to replace
a custom highlighter i made for some C-ish scripting that used RichEdit and
was a lot slower, SynEdit even allowed nice access to the parsed content so
you could even build your interpreter without writing your own parser :)
Now this is most interesting for me. The question is obvious: has anyone ever built an interpreter with Synedit and what could be the best way to achieve this?
--
Best regards

cybermonkey342

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit general question
« Reply #1 on: March 07, 2013, 11:45:25 pm »
I don't think the author quite meant what he wrote.

Yes SynEdit is fast. Including some fast highlighters.

But as for using it as a base to an interpreter: All the build in highlighters simply ignore errors, so you still get highlighting.  And they have NO indicator that there is an ignored error.

An interpreter is not allowed to ignore errors.

So you can't use a build in highlighter for that. Besides: Yes you can get some of the highlight info, but it is not that easy, but you would still have to parse it.

The highlighters only says something like this is an operator (+-*1:=), you then  still need to check which one, and check if it can be used in that context.


The highlighter will return highlight for:
Code: [Select]
  'string' := 1;

But that can not be executed/interpreted.

Of course you can write your own highlighter, but then why not write the interpreter directly.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Synedit general question
« Reply #2 on: March 08, 2013, 01:21:35 am »
I wouldn't suggest using SynEdit as a base for interpreter. Writing the whole interpreter yourself it better. SynEdit only provides syntax highlighting (and with Lazarus modificaton, also semantic highlighting) but this is mostly works on token level, that is, it only lex the source code, no syntax checking or semantic checking whatsoever which is required by a compiler/interpreter.

cybermonkey342

  • New Member
  • *
  • Posts: 42
    • Home of EGSL interpreter
Re: Synedit general question
« Reply #3 on: March 08, 2013, 12:08:12 pm »
Ok, then I might take another look at pyacc/plex or the Goldparser. The story behind that is that I wanted to port an exisiting interpreter written in Ansic C and bison/flex to Pascal. So a handmade parser/lexer isn't that useful (since all grammars are available.)
--
Best regards

cybermonkey342

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Synedit general question
« Reply #4 on: March 08, 2013, 02:27:32 pm »
Quote
The story behind that is that I wanted to port an exisiting interpreter written in Ansic C and bison/flex to Pascal
Maybe you could go fpr pyacc/plex, since they're closer. you may only need to modify actions and user code in the parser spec.

 

TinyPortal © 2005-2018