jEdit Community - Resources for users of the jEdit Text Editor
mode syntax function (...) {...}
Submitted by captainhunt on Wednesday, 28 September, 2011 - 14:08
Hi there,

I am trying to write a mode for a simulator. The syntax looks like

Quasistationary (<options>) {<equations>}
Transient (<options>) {<equations>}
I'd like to match Quasistationary and Transient separately and somehow handle the <options> and <equations> in different rules. I tried something like:
<SPAN_REGEXP TYPE="KEYWORD3" DELEGATE="QS_OPTION"><BEGIN>Quasistationary\s*\(</BEGIN><END>)</END></SPAN_REGEXP>
<SPAN_REGEXP TYPE="KEYWORD3" DELEGATE="QS_EQ"><BEGIN>.*\{</BEGIN><END>}</END></SPAN_REGEXP>
<SPAN_REGEXP TYPE="KEYWORD3" DELEGATE="TRANS_OPTION"><BEGIN>Transient\s*\(</BEGIN><END>)</END></SPAN_REGEXP>
<SPAN_REGEXP TYPE="KEYWORD3" DELEGATE="TRANS_EQ"><BEGIN>.*{</BEGIN><END>}</END></SPAN_REGEXP>
However, the problem with this approach is, that Transient equations (line 4) are captured by the Quasistationary equations (line 2) already.

Any ideas how to solve this?

Thanks in advance
Captainhunt

Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
cascading
by Robert Schwenn on Sun, 02/10/2011 - 22:07
My first idea was to delegate the whole lines to Quasistationary and Transient rules and then parse and delegate options and equations. But I'm not sure that such cascading is supported Eye-wink

Robert
 
Re: cascading
by captainhunt on Mon, 03/10/2011 - 07:33
Hi Robert,

I thought about this, however the first challenge would then be to correctly extract the complete quasistationary block as it can be quite complex structure e.g.:

Quasistationary (
InitialStep=0.2 MaxStep=1 MinStep=0.01
Plot { Range = ( 0., 1 ) Intervals = 5 }
Goal { ModelParameter="Optics/Excitation/Window(L2)/Origin[0]" value=0.9 }) {
  Coupled (Iterations=50)  {Poisson Electron Hole}
}
The only reliable way would be a SPAN_REGEXP, using quasistationary( as start exp, and } as end tag. But then the main problem still exists: How to separate the optionblock from equationblock.

Best regards,
Gergoe

 
hmm
by Robert Schwenn on Mon, 03/10/2011 - 10:59
Hi, I thought Your main problem was to tell Transient equations from Quasistationary equations?

But I guess that Your rules don't work at all, because the end tags never find matching brackets but the next or maybe the last one. Am I wrong? I'm not sure how it would be possible to find matching brackets via Regular expressions.

If You don't too, You could ask at the Mailing List ( https://lists.sourceforge.net/lists/listinfo/jedit-devel ). There are the developers.

Robert
User login
Browse archives
« January 2018  
MoTuWeThFrSaSu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
33%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1092
Syndication
file   ver   dls
German Localization light   4.4.2.1   50945
Context Free Art (*.cfdg)   0.31   41165
JBuilder scheme   .001   16997
BBEdit scheme   1.0   16596
ColdFusion scheme   1.0   16582
R Edit Mode - extensive version   0.1   14862
Advanced HTML edit mode   1.0   14043
Matlab Edit Mode   1.0   13979
jEdit XP icons   1.0   13412
XP icons for jEdit   1.1   12435