Hello! There is one fairly large project on MATLAB, which is desirable to translate into C #

The project is written by classes, the sample code below, the code itself is made similar to a sharpe.

I perfectly understand that it will be necessary to arrange types, to do some interfaces, that I can hardly find automated utilities, and that it will be necessary to nip it with my hands, but the volume is frightening - several thousand (xs, 3-4 thousand) lines of code.

Are there at least some syntax converters so as not to change all these functions .... end, if ... end, for ... end to classical syntax with curly braces? Sample code. All code in this OOP style: class-methods is inheritance, there are events

classdef ENode<handle properties nodes_range connected_elements={}; is_repacked=false end methods function copy_object=Clone(this) constructor=str2func(class(this)); copy_object=constructor(this.nodes_range); %!!! У КОПИИ is_repacked=false!!! end function this=ENode(nodes_range) if nargin==1 this.nodes_range=nodes_range; end end function RefreshNodeRange(this,deleted_range) if ~isempty(deleted_range) has_selfnode_deleted=false; new_range=this.nodes_range; for i=1:length(deleted_range) for j=1:length(this.nodes_range) if deleted_range(i)<this.nodes_range(j) new_range(j)=new_range(j)-1; elseif deleted_range(i)==this.nodes_range(j) new_range(j)=0; has_selfnode_deleted=true; end end end if has_selfnode_deleted k=1; while 1 if new_range(k)==0 new_range=[]; else k=k+1; end if k>length(this.nodes_range) break end end end this.nodes_range=new_range; end end end end 
  • I don’t know if you will find such a utility, but as a first approximation you can write a very small parser utility code parser that will take your function ... end, if ... end and for ... end to replace with C # your own code . end is simply replaced with a closing brace. With the beginning of the block a little more difficult, but possible. - Oleg Klezovich
  • one
    3-4 thousand code is actually not so much :-) You need to worry about the possibilities of MatLab that are difficult to implement in C # (special mathematical functions), and not function...end , etc. - user227049
  • The specific question is what? - Ev_Hyper
  • In how (with the help of which tools it is better) to make a parser for replacing pieces of matlab syntax with sharpe, mainly it is if, switch, for, while, function. I will do the rest with my hands. Maybe there are parsers for languages ​​with similar syntax? - retriever

0