Skip to content

Commit

Permalink
Work on rendering theories.
Browse files Browse the repository at this point in the history
  • Loading branch information
weetmuts committed Jul 9, 2024
1 parent b3be1c8 commit 6515612
Show file tree
Hide file tree
Showing 9 changed files with 396 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/main/java/com/viklauverk/eventbtools/core/RenderOperator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright (C) 2021-2024 Viklauverk AB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viklauverk.eventbtools.core;

import java.util.List;
import java.util.LinkedList;

import com.viklauverk.eventbtools.core.Formula;

public class RenderOperator extends CommonRenderFunctions
{
public void visit_OperatorStart(Operator oprt) { }

public void visit_HeadingComplete(Operator oprt) { }

public void visit_OperatorEnd(Operator oprt) { }

protected String buildOperatorPartName(Operator oprt)
{
return oprt.theory().name()+"/"+oprt.name();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Copyright (C) 2021-2024 Viklauverk AB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viklauverk.eventbtools.core;

public class RenderOperatorUnicode extends RenderOperator
{
@Override
public void visit_OperatorStart(Operator oprt)
{
String id = buildOperatorPartName(oprt);

cnvs().marker(id);

cnvs().startLine();
if (oprt.notation() == OperatorNotationType.PREFIX)
{
cnvs().keywordLeft("prefix ");
}
if (oprt.notation() == OperatorNotationType.INFIX)
{
cnvs().keywordLeft("infix ");
}
cnvs().keywordLeft("operator ");
cnvs().id(oprt.name());
cnvs().endLine();

if (oprt.hasComment())
{
cnvs().acomment(oprt.comment());
}
}

@Override
public void visit_HeadingComplete(Operator oprt)
{
}

@Override
public void visit_OperatorEnd(Operator oprt)
{
cnvs().startLine();
cnvs().keyword("end");
cnvs().endLine();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Copyright (C) 2021-2024 Viklauverk AB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viklauverk.eventbtools.core;

import java.util.List;
import java.util.LinkedList;

import com.viklauverk.eventbtools.core.Formula;

public class RenderPolymorphicDataType extends CommonRenderFunctions
{
public void visit_PolymorphicDataTypeStart(PolymorphicDataType pdt) { }

public void visit_HeadingComplete(PolymorphicDataType pdt) { }

public void visit_ConstructorsStart(PolymorphicDataType pdt) { }
public void visit_Constructor(PolymorphicDataType pdt, Constructor cnstr) { }
public void visit_ConstructorsEnd(PolymorphicDataType pdt) { }

public void visit_PolymorphicDataTypeEnd(PolymorphicDataType pdt) { }

protected String buildPolymorphicDataTypePartName(PolymorphicDataType pdt)
{
return pdt.theory().name()+"/"+pdt.baseName();
}

protected String buildConstructorsPartName(PolymorphicDataType pdt)
{
return pdt.theory().name()+"/"+pdt.baseName()+"/constructors";
}

protected String buildConstructorPartName(PolymorphicDataType pdt, Constructor cnstr)
{
return pdt.theory().name()+"/"+pdt.baseName()+"/constructor/"+cnstr.name();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright (C) 2024 Viklauverk AB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viklauverk.eventbtools.core;

public class RenderPolymorphicDataTypeHtmq extends RenderPolymorphicDataTypeUnicode
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright (C) 2024 Viklauverk AB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viklauverk.eventbtools.core;

public class RenderPolymorphicDataTypeSearch extends RenderPolymorphicDataType
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (C) 2021-2024 Viklauverk AB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viklauverk.eventbtools.core;

public class RenderPolymorphicDataTypeTeX extends RenderPolymorphicDataTypeUnicode
{
@Override
public void visit_PolymorphicDataTypeStart(PolymorphicDataType pdt)
{
cnvs().append("\\subsection{\\footnotesize ");
cnvs().set(pdt.longName());
cnvs().append(" ");
cnvs().append("}\n");
super.visit_PolymorphicDataTypeStart(pdt);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright (C) 2021-2024 Viklauverk AB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viklauverk.eventbtools.core;

public class RenderPolymorphicDataTypeUnicode extends RenderPolymorphicDataType
{
@Override
public void visit_PolymorphicDataTypeStart(PolymorphicDataType pdt)
{
String id = buildPolymorphicDataTypePartName(pdt);

cnvs().marker(id);

if (pdt.hasComment())
{
cnvs().acomment(pdt.comment());
}
cnvs().startLine();
cnvs().id(pdt.longName());
cnvs().endLine();
}

@Override
public void visit_ConstructorsStart(PolymorphicDataType pdt)
{
cnvs().startLine();
cnvs().keywordLeft("► ");
cnvs().space();
}

@Override
public void visit_Constructor(PolymorphicDataType pdt, Constructor cnstr)
{
//renders().walkConstructor(pdt, "");
}

@Override
public void visit_ConstructorsEnd(PolymorphicDataType pdt)
{
cnvs().endLine();
}

@Override
public void visit_HeadingComplete(PolymorphicDataType pdt)
{
}

@Override
public void visit_PolymorphicDataTypeEnd(PolymorphicDataType pdt)
{
cnvs().startLine();
cnvs().keyword("end");
cnvs().endLine();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright (C) 2021-2024 Viklauverk AB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viklauverk.eventbtools.core;

import java.util.List;
import java.util.LinkedList;

import com.viklauverk.eventbtools.core.Formula;

public class VisitPolymorphicDataType
{
public static void walk(RenderPolymorphicDataType re, PolymorphicDataType pdt, String pattern)
{
String path = pdt.theory().name()+"/datatypes/"+pdt.baseName()+"/";
boolean m = Util.match(path, pattern);

if (m) re.visit_PolymorphicDataTypeStart(pdt);

if (m) re.visit_HeadingComplete(pdt);

if (pdt.hasConstructors())
{
if (m) re.visit_ConstructorsStart(pdt);
for (Constructor cnstr : pdt.constructorOrdering())
{
boolean pp = Util.match(path+"constructors/"+cnstr.name()+"/", pattern);
if (pp) re.visit_Constructor(pdt, cnstr);
}
if (m) re.visit_ConstructorsEnd(pdt);
}

if (m) re.visit_PolymorphicDataTypeEnd(pdt);
}
}
Loading

0 comments on commit 6515612

Please sign in to comment.