neharob / editra

Automatically exported from code.google.com/p/editra
Other
0 stars 0 forks source link

Lexer for GLPK/MathProg (GMPL) #540

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Opening any .mod, .mps, .lp, glp source in editra.
2.

Currently we are using SciTE and GUSEK but there is no support for Mac OS X.

http://www.gnu.org/software/glpk/

http://www.mail-archive.com/help-glpk@gnu.org/msg03812.html

What is the expected output? What do you see instead?
Syntax highlighting in GLPK/MathProg programs.

IMPORTANT!!! Please answer these questions for any and ALL bug reports

What version of the product are you using? On what operating system?
For Windows XP and 7, Mac OS X and Linux

What method of install was your version installed with (Binary/Source)?

If from source: What version of python and wxPython are you using?

Here is glpk.properties for GUSEK/SciTE

~ GUSEK - Settings for glpk files

file.patterns.gmpl=.mod;.dat file.patterns.gmps=.mps file.patterns.gclp=.lp file.patterns.gout=.out file.patterns.glp=.glp file.patterns.gall=$(file.patterns.gmpl);$(file.patterns.gmps);$(file.patterns.g clp);$(file.patterns.gout);$(file.patterns.glp) filter.gmpl=GMPL (mod dat)|$(file.patterns.gmpl)| filter.gmps=MPS (mps)|$(file.patterns.gmps)| filter.gclp=Cplex LP (lp)|$(file.patterns.gclp)| filter.gout=GLPK Output (out)|$(file.patterns.gout)| filter.gout=GLPK LP/MIP Format (glp)|$(file.patterns.glp)| filter.gall=All GLPK Files (mod dat mps lp out glp)|$(file.patterns.gall)|

lexer.$(file.patterns.gmpl)=sql word.characters.$(file.patterns.gmpl)=_.$(chars.alpha)$(chars.numeric) keywords.$(file.patterns.gmpl)=\ abs and atan binary by card ceil check cos cross cross data default \ diff diff dimen display div else end exists exp floor for forall if in integer inter Irand224 length less \ log log10 max maximize min minimize mod Normal Normal01 not or param printf prod round s.t. set setof \ sin solve sqrt subj subject substr sum symbolic symdiff then to tr trunc Uniform Uniform01 union var within \ table out \ gmtime str2time time2str

lexer..out=sql word.characters..out=_.$(chars.alpha)$(chars.numeric) keywords.*.out=\ problem rows columns non zeros status objective end of output \ no row column name st activity lower upper bound marginal \ coefficient analysis value max increase decrease constraint variable bounds

lexer..lp=sql word.characters..lp=_.$(chars.alpha)$(chars.numeric) keywords.*.lp=\ minimize minimum min maximize maximum max subject to such that s.t. st. st \ bounds bound general generals gen integer integers int binary binaries bin infinity inf free end

lexer..mps=sql word.characters..mps=_.$(chars.alpha)$(chars.numeric) keywords.*.mps=\ name rows columns rhs ranges bounds endata \ n g l e xl xu ll ul lo up fx fr mi pl li ui bv

lexer..glp=asm word.characters..mps=_.$(chars.alpha)$(chars.numeric) keywords.*.glp=\ c b f l u d s p z i j e n a

default font

style.sql.32=fore:#000000,$(font.monospace)

operators

style.sql.10=fore:#405570,bold

keywords2 - null collor

style.sql.16=fore:#000000

Hash Line Comment

style.sql.2=fore:#999999

api.$(file.patterns.gmpl)=$(SciteDefaultHome)/gmpl.api abbreviations.$(file.patterns.gmpl)=$(SciteDefaultHome)/gmpl.abb autocomplete.sql.start.characters=( autocomplete.sql.fillups=( autocomplete.sql.ignorecase=1 calltip.sql.parameters.start=( calltip.sql.parameters.end=) calltip.sql.parameters.separators=, calltip.sql.ignorecase=1 calltip.sql.end.definition=) calltip.sql.word.characters=_$(chars.alpha)$(chars.numeric)

comment.block.sql=# comment.block.at.line.start.sql=1 comment.stream.start.sql=/ comment.stream.end.sql=/ comment.box.start.sql=/ comment.box.middle.sql= comment.box.end.sql=*/

asm lexer for glp files

Assembler Styles

style.asm.32=fore:#000000,$(font.monospace)

Comment

style.asm.1=$(colour.code.comment.line),$(font.comment)

Number

style.asm.2=$(colour.number)

Comments

comment.block.asm=c

~ Help files

command.help.$(file.patterns.gmpl)="file://$(SciteDefaultHome)/gmpl.pdf" command.help.$(file.patterns.gmps)="file://$(SciteDefaultHome)/glpk.pdf" command.help.$(file.patterns.gclp)="file://$(SciteDefaultHome)/glpk.pdf" command.help.$(file.patterns.glp)="file://$(SciteDefaultHome)/glpk.pdf" command.help.subsystem.$(file.patterns.gall)=2

To check model language

command.compile.$(file.patterns.gmpl)=$(SciteDefaultHome)\glpsol.exe --check
$(1) -m "$(FileName).mod" $(2) $(3) command.compile.$(file.patterns.gmps)=$(SciteDefaultHome)\glpsol.exe --check
$(1) --$(mpstype) "$(FileNameExt)" command.compile.$(file.patterns.gclp)=$(SciteDefaultHome)\glpsol.exe --check
$(1) --lp "$(FileNameExt)" command.compile.$(file.patterns.glp)=$(SciteDefaultHome)\glpsol.exe --check
$(1) --glp "$(FileNameExt)"

To run model

command.go.needs.subsystem.$(file.patterns.gmpl)=0 command.go.needs.$(file.patterns.gmpl)=$(SciteDefaultHome)\glpsol.exe $(1) -m "$(FileName).mod" $(doout) $(dobnd) $(2) $(3) command.go.subsystem.$(file.patterns.gmpl)=3 command.go.$(file.patterns.gmpl)= dostring \ if ("$(opnout)"~="") then scite.Open("$(opnout)") end \ if ("$(opnbnd)"~="") then scite.Open("$(opnbnd)") end

command.go.needs.subsystem.$(file.patterns.gmps)=0 command.go.needs.$(file.patterns.gmps)=$(SciteDefaultHome)\glpsol.exe $(1) --$(mpstype) "$(FileNameExt)" $(doout) $(dobnd) command.go.subsystem.$(file.patterns.gmps)=3 command.go.$(file.patterns.gmps)= dostring \ if ("$(opnout)"~="") then scite.Open("$(opnout)") end \ if ("$(opnbnd)"~="") then scite.Open("$(opnbnd)") end

command.go.needs.subsystem.$(file.patterns.gclp)=0 command.go.needs.$(file.patterns.gclp)=$(SciteDefaultHome)\glpsol.exe $(1) --lp "$(FileNameExt)" $(doout) $(dobnd) command.go.subsystem.$(file.patterns.gclp)=3 command.go.$(file.patterns.gclp)= dostring \ if ("$(opnout)"~="") then scite.Open("$(opnout)") end \ if ("$(opnbnd)"~="") then scite.Open("$(opnbnd)") end

command.go.needs.subsystem.$(file.patterns.glp)=0 command.go.needs.$(file.patterns.glp)=$(SciteDefaultHome)\glpsol.exe $(1) --glp "$(FileNameExt)" $(doout) $(dobnd) command.go.subsystem.$(file.patterns.glp)=3 command.go.$(file.patterns.glp)= dostring \ if ("$(opnout)"~="") then scite.Open("$(opnout)") end \ if ("$(opnbnd)"~="") then scite.Open("$(opnbnd)") end

To build GLPK LP model

nomecom0=Build GLPK LP/MIP filepatcom0=$(file.patterns.gmpl);$(file.patterns.gmps);$(file.patterns.gclp) command.name.0.$(filepatcom0)=$(nomecom0) command.subsystem.0.$(filepatcom0)=0 command.save.before.0.$(filepatcom0)=1 command.shortcut.0.$(filepatcom0)=Ctrl+1 command.separator.0.$(filepatcom0)=1

command.0.$(file.patterns.gmpl)=cmd /c path=%path%;$(SciteDefaultHome)\ && glpsol.exe --check $(1) -m "$(FileName).mod" --wglp $(FileName).glp $(2) $(3)\ && gusek.exe -open:$(FileName).glp

command.0.$(file.patterns.gmps)=cmd /c path=%path%;$(SciteDefaultHome)\ && glpsol.exe --check $(1) --$(mpstype) "$(FileNameExt)" --wglp $(FileName).glp \ && gusek.exe -open:$(FileName).glp

command.0.$(file.patterns.gclp)=cmd /c path=%path%;$(SciteDefaultHome)\ && glpsol.exe --check $(1) --lp "$(FileNameExt)" --wglp $(FileName).glp \ && gusek.exe -open:$(FileName).glp

To build CPLEX LP model

nomecom1=Build Cplex LP filepatcom1=$(file.patterns.gmpl);$(file.patterns.gmps);$(file.patterns.glp) command.name.1.$(filepatcom1)=$(nomecom1) command.subsystem.1.$(filepatcom1)=0 command.save.before.1.$(filepatcom1)=1 command.shortcut.1.$(filepatcom1)=Ctrl+2 command.separator.1.$(file.patterns.glp)=1

command.1.$(file.patterns.gmpl)=cmd /c path=%path%;$(SciteDefaultHome)\ && glpsol.exe --check $(1) -m "$(FileName).mod" --wlp $(FileName).lp $(2) $(3)\ && gusek.exe -open:$(FileName).lp

command.1.$(file.patterns.gmps)=cmd /c path=%path%;$(SciteDefaultHome)\ && glpsol.exe --check $(1) --$(mpstype) "$(FileNameExt)" --wlp $(FileName).lp \ && gusek.exe -open:$(FileName).lp

command.1.$(file.patterns.glp)=cmd /c path=%path%;$(SciteDefaultHome)\ && glpsol.exe --check $(1) --glp "$(FileNameExt)" --wlp $(FileName).lp \ && gusek.exe -open:$(FileName).lp

To build MPS matrix

nomecom2=Build MPS filepatcom2=$(file.patterns.gmpl);$(file.patterns.gclp);$(file.patterns.glp) command.name.2.$(filepatcom2)=$(nomecom2) command.subsystem.2.$(filepatcom2)=0 command.save.before.2.$(filepatcom2)=1 command.shortcut.2.$(filepatcom2)=Ctrl+3

command.2.$(file.patterns.gmpl)=cmd /c path=%path%;$(SciteDefaultHome)\ && glpsol.exe --check $(1) -m "$(FileName).mod" --w$(mpstype) $(FileName).mps $(2) $(3)\ && gusek.exe -open:$(FileName).mps

command.2.$(file.patterns.gclp)=cmd /c path=%path%;$(SciteDefaultHome)\ && glpsol.exe --check $(1) --lp "$(FileNameExt)" --w$(mpstype) $(FileName).mps\ && gusek.exe -open:$(FileName).mps

command.2.$(file.patterns.glp)=cmd /c path=%path%;$(SciteDefaultHome)\ && glpsol.exe --check $(1) --glp "$(FileNameExt)" --w$(mpstype) $(FileName).mps\ && gusek.exe -open:$(FileName).mps

To togle use of external .dat file

ckmn4=0 datnaming=Use External .dat command.name.4.$(file.patterns.gmpl)=$(datnaming) command.4.$(file.patterns.gmpl)=gusek_datparam() command.subsystem.4.$(file.patterns.gmpl)=3 command.mode.4.$(file.patterns.gmpl)=savebefore:no command.shortcut.4.$(file.patterns.gmpl)=Ctrl+4 command.checked.4.$(file.patterns.gmpl)=$(ckmn4) command.separator.4.$(file.patterns.gmpl)=1

To define a global dat file

nomecom5=Set as Default .dat File command.name.5..dat=$(nomecom5) command.5..dat=guseksetdat() command.subsystem.5..dat=3 command.mode.5._.dat=savebefore:no command.shortcut.5.*.dat=Ctrl+5

To add extra dat files

nomecom6=Add as Extra .dat File command.name.6..dat=$(nomecom6) command.6..dat=gusekadddat() command.subsystem.6..dat=3 command.mode.6._.dat=savebefore:no command.shortcut.6.*.dat=Ctrl+6

To clear extra dat files

nomecom7=Clear Extra .dat Files command.name.7.$(file.patterns.gmpl)=$(nomecom7) command.7.$(file.patterns.gmpl)=gusek_clrdat() command.subsystem.7.$(file.patterns.gmpl)=3 command.mode.7.$(file.patterns.gmpl)=savebefore:no command.shortcut.7.$(file.patterns.gmpl)=Ctrl+7

To togle use and open of out files

ckmn2=0 nomecom10=Generate Output File on Go command.name.10.$(file.patterns.gall)=$(nomecom10) command.10.$(file.patterns.gall)=gusek_openout() command.subsystem.10.$(file.patterns.gall)=3 command.mode.10.$(file.patterns.gall)=savebefore:no command.shortcut.10.$(file.patterns.gall)=Ctrl+8 command.checked.10.$(file.patterns.gall)=$(ckmn2) command.separator.10.$(file.patterns.gall)=1

To togle use and open of sensivity out files

ckmn9=0 nomecom11=Generate LP Sensitivity Analysis command.name.11.$(file.patterns.gall)=$(nomecom11) command.11.$(file.patterns.gall)=gusek_openbnd() command.subsystem.11.$(file.patterns.gall)=3 command.mode.11.$(file.patterns.gall)=savebefore:no command.shortcut.11.$(file.patterns.gall)=Ctrl+9 command.checked.11.$(file.patterns.gall)=$(ckmn9)

To togle use of milp parameters

ckmn3=1

default values:

1=--cover --clique --gomory --mir milpnaming=Use Improved MILP (All Cuts) command.name.13.$(file.patterns.gall)=$(milpnaming) command.13.$(file.patterns.gall)=gusek_milpopt() command.subsystem.13.$(file.patterns.gall)=3 command.mode.13.$(file.patterns.gall)=savebefore:no command.shortcut.13.$(file.patterns.gall)=Ctrl+Shift+1 command.checked.13.$(file.patterns.gall)=$(ckmn3) command.separator.13.$(file.patterns.gall)=1

To toggle between Fixed and Free MPS

ckmn8=0

default vaule. must be 'mps' or 'freemps' (no quotes). toogle bin value for

ckmn8 too. mpstype=mps nomecom14=Use Free MPS Format command.name.14.$(file.patterns.gall)=$(nomecom14) command.14.$(file.patterns.gall)=gusek_fixmps() command.subsystem.14.$(file.patterns.gall)=3 command.mode.14.$(file.patterns.gall)=savebefore:no command.shortcut.14.$(file.patterns.gall)=Ctrl+Shift+2 command.checked.14.$(file.patterns.gall)=$(ckmn8)


Original issue reported on code.google.com by `nsi...@gmail.com` on 8 Sep 2010 at 12:48
GoogleCodeExporter commented 9 years ago
Hi,

Guessing that you are asking to add support for this file type?

Do you know what lexer is used by Scite to do the highlighting? Editra doesn't 
use properties files so you can't just copy that over and use it.

Can you attach a small Hello World like example code of GLPK/MatProg? So there 
is something to test against.

Thanks,

Cody

Original comment by CodyPrec...@gmail.com on 8 Sep 2010 at 1:33

GoogleCodeExporter commented 9 years ago
Hi Cody,

As mentioned in my email to you that the glpk lexer piggyback with the sql 
lexer as you see the above posting. It uses the sql lexer for highlighting.

I tried to create a _glpk file using xtext but the lightning outcomes is not so 
good.

I am attaching here the equivalent Hello World example file. In glpk case, 
transporation model i.e. transp.mod and transp.lp. These are 2 of the 5 file 
extension in glpk.

Original comment by nsi...@gmail.com on 9 Sep 2010 at 2:42

Attachments:

GoogleCodeExporter commented 9 years ago
Why did you try the xtext one when you said you used sql lexer in scite? 
Wouldn't it be better to try and create a new one based on the existing _sql 
file? The xtext lexer is a good example of a custom lexer that is not builtin 
to scintilla though so if pygments has a lexer for glpk then it could probably 
be leveraged to provide better highlighting.

I think some additional modifications to Editra's framework will have to be 
made to support the multiple filetypes for the same language. Will have to 
think about it some but shouldn't be a big deal. Will be on a business trip the 
next week so hopefully will have some time after that to look into it more.

Original comment by CodyPrec...@gmail.com on 10 Sep 2010 at 1:16

GoogleCodeExporter commented 9 years ago
Thanks.

I am looking at the _sql and other lexers, probably _cpp lexer might good as 
well.

I don't where you actually put the various file extensions. This is the reason 
why I use xtext lexer.

Original comment by nsi...@gmail.com on 10 Sep 2010 at 1:51

GoogleCodeExporter commented 9 years ago
Hi,

See: syntax/synextreg.py

There is a table in there that has the default associations.

Original comment by CodyPrec...@gmail.com on 10 Sep 2010 at 2:12