missing plugins added

This commit is contained in:
Бондарев Иван 2015-05-14 22:56:23 +02:00
parent e6e67c193c
commit d146d5bdd7
19 changed files with 4049 additions and 0 deletions

View file

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{43879684-ADBE-470A-AAC6-2ACA36603971}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Converter</RootNamespace>
<AssemblyName>LanguageConverter</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>4.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Source\ISemanticNodeConverter.cs" />
<Compile Include="Source\SemanticNodeConverter.cs" />
<Compile Include="Source\ListSyntRules.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Source\LanguageConverterPlugin.cs" />
<Compile Include="Source\SourceTextBilder.cs" />
<Compile Include="Source\TextFormatterForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Source\TextFormatterForm.Designer.cs">
<DependentUpon>TextFormatterForm.cs</DependentUpon>
</Compile>
<Compile Include="Source\Visitor.cs" />
<Compile Include="Source\TextFormatter.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<SubType>Designer</SubType>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Source\TextFormatterForm.resx">
<SubType>Designer</SubType>
<DependentUpon>TextFormatterForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="Source\Rules_CS.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CompilerTools\CompilerTools.csproj">
<Project>{A25D26FB-3043-4BCF-833E-E3F4C3BE795E}</Project>
<Name>CompilerTools</Name>
</ProjectReference>
<ProjectReference Include="..\..\Compiler\Compiler.csproj">
<Project>{1E42361A-EDA3-4872-88AF-A3AAF600D36D}</Project>
<Name>Compiler</Name>
</ProjectReference>
<ProjectReference Include="..\..\Errors\Errors.csproj">
<Project>{44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}</Project>
<Name>Errors</Name>
</ProjectReference>
<ProjectReference Include="..\..\Localization\Localization.csproj">
<Project>{2DE2842F-0912-4251-BC0F-480854C44A13}</Project>
<Name>Localization</Name>
</ProjectReference>
<ProjectReference Include="..\..\PluginsSupport\PluginsSupport.csproj">
<Project>{CFC683F8-0165-4A9F-9C3F-BB8C5BAB507F}</Project>
<Name>PluginsSupport</Name>
</ProjectReference>
<ProjectReference Include="..\..\SemanticTree\SemanticTree.csproj">
<Project>{613E0DDA-AA8A-437C-AC45-507B47429FF9}</Project>
<Name>SemanticTree</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>Клиентский профиль .NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Установщик Windows 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Converter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Luba-slon")]
[assembly: AssemblyProduct("Converter")]
[assembly: AssemblyCopyright("Copyright © Luba-slon 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ce68e2c8-c330-4005-8b30-bf47130600a8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.1
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Converter.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Converter.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,77 @@
using System;
namespace Converter
{
public interface ISemanticNodeConverter
{
string ConvertPABCNETNodeAdd(string _nodeName, object _node);
string ConvertPABCNETNodeAnd(string _nodeName, object _node);
string ConvertPABCNETNodeAssign(string _nodeName, object _node);
string ConvertPABCNETNodeBlock(string _nodeName, object _node);
string ConvertPABCNETNodeBoolConstant(string _nodeName, object _node);
string ConvertPABCNETNodeByteConstant(string _nodeName, object _node);
string ConvertPABCNETNodeCharConstant(string _nodeName, object _node);
string ConvertPABCNETNodeClass(string _nodeName, object _node);
string ConvertPABCNETNodeDec(string _nodeName, object _node);
string ConvertPABCNETNodeDiv(string _nodeName, object _node);
string ConvertPABCNETNodeDoubleConstant(string _nodeName, object _node);
string ConvertPABCNETNodeEq(string _nodeName, object _node);
string ConvertPABCNETNodeFloatConstant(string _nodeName, object _node);
string ConvertPABCNETNodeFor(string _nodeName, object _node);
string ConvertPABCNETNodeFunction(string _nodeName, object _node);
string ConvertPABCNETNodeFunctionCall(string _nodeName, object _node);
string ConvertPABCNETNodeGr(string _nodeName, object _node);
string ConvertPABCNETNodeGrEq(string _nodeName, object _node);
string ConvertPABCNETNodeIf(string _nodeName, object _node);
string ConvertPABCNETNodeInc(string _nodeName, object _node);
string ConvertPABCNETNodeIntConstant(string _nodeName, object _node);
string ConvertPABCNETNodeLocalBlockVariable(string _nodeName, object _node);
string ConvertPABCNETNodeLocVariableReference(string _nodeName, object _node);
string ConvertPABCNETNodeLongConstant(string _nodeName, object _node);
string ConvertPABCNETNodeMod(string _nodeName, object _node);
string ConvertPABCNETNodeMult(string _nodeName, object _node);
string ConvertPABCNETNodeNamespace(string _nodeName, object _node);
string ConvertPABCNETNodeNamespaceConst(string _nodeName, object _node);
string ConvertPABCNETNodeNamespaceVariable(string _nodeName, object _node);
string ConvertPABCNETNodeBinNot(string _nodeName, object _node);
string ConvertPABCNETNodeUnNot(string _nodeName, object _node);
string ConvertPABCNETNodeNotEq(string _nodeName, object _node);
string ConvertPABCNETNodeNullConst(string _nodeName, object _node);
string ConvertPABCNETNodeOr(string _nodeName, object _node);
string ConvertPABCNETNodeParameter(string _nodeName, object _node);
string ConvertPABCNETNodeParameterReference(string _nodeName, object _node);
string ConvertPABCNETNodeProgram(string _nodeName, object _node);
string ConvertPABCNETNodeRepeat(string _nodeName, object _node);
string ConvertPABCNETNodeReturn(string _nodeName, object _node);
string ConvertPABCNETNodeSByteConstant(string _nodeName, object _node);
string ConvertPABCNETNodeShl(string _nodeName, object _node);
string ConvertPABCNETNodeShortConstant(string _nodeName, object _node);
string ConvertPABCNETNodeShr(string _nodeName, object _node);
string ConvertPABCNETNodeSimpleArrInd(string _nodeName, object _node);
string ConvertPABCNETNodeSm(string _nodeName, object _node);
string ConvertPABCNETNodeSmEq(string _nodeName, object _node);
string ConvertPABCNETNodeStatements(string _nodeName, object _node);
string ConvertPABCNETNodeStatementsNested(string _nodeName, object _node);
string ConvertPABCNETNodeStaticMethodCall(string _nodeName, object _node);
string ConvertPABCNETNodeStringConstant(string _nodeName, object _node);
string ConvertPABCNETNodeSubtract(string _nodeName, object _node);
string ConvertPABCNETNodeType(string _nodeName, object _node);
string ConvertPABCNETNodeTypeOf(string _nodeName, object _node);
string ConvertPABCNETNodeUIntConstant(string _nodeName, object _node);
string ConvertPABCNETNodeULongConstant(string _nodeName, object _node);
string ConvertPABCNETNodeUnMin(string _nodeName, object _node);
string ConvertPABCNETNodeUShortConstant(string _nodeName, object _node);
string ConvertPABCNETNodeVariable(string _nodeName, object _node);
string ConvertPABCNETNodeVariableReference(string _nodeName, object _node);
string ConvertPABCNETNodeWhile(string _nodeName, object _node);
string ConvertPABCNETNodeXor(string _nodeName, object _node);
string GetConvertedText();
SourceTextBilder SourceTextBuilder { get; set; }
string ConvertPABCNETNodeConstructorCall(string _nodeName, object _node);
string ConvertPABCNETNodeCompMethodCall(string _nodeName, object _node);
string ConvertPABCNETNodeIfElse(string _nodeName, object _node);
string ConvertPABCNETNodeUnInc(string _nodeName, object _node);
string ConvertPABCNETNodeUnDec(string _nodeName, object _node);
}
}

View file

@ -0,0 +1,169 @@
using System;
using System.Collections.Generic;
using System.Text;
using Converter;
using System.IO;
namespace VisualPascalABCPlugins
{
public class LanguageConverter_VisualPascalABCPlugin : IVisualPascalABCPlugin
{
public static string StringsPrefix = "VPP_LNGCONVERT_";
IVisualEnvironmentCompiler VisualEnvironmentCompiler;
internal ISemanticNodeConverter currentLanguage;
private TextFormatterForm TextFormatterForm;
//public TextFormatter TextFormatter;
public List<ISemanticNodeConverter> Languages;
public string Name
{
get
{
return "Language Converter";
}
}
public string Version
{
get
{
return "0.1";
}
}
public string Copyright
{
get
{
return "(c) 2008";
}
}
public void OpenFilesInEnvironment(List<string> fileNames)
{
foreach (string name in fileNames)
VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.OpenFile, name);
}
public void ExecuteBuild()
{
MyCompilation = true;
VisualEnvironmentCompiler.StandartCompiler.InternalDebug.CodeGeneration = false;
PascalABCCompiler.CompilerType ct = VisualEnvironmentCompiler.DefaultCompilerType;
VisualEnvironmentCompiler.DefaultCompilerType = PascalABCCompiler.CompilerType.Standart;
VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.Build, null);
VisualEnvironmentCompiler.DefaultCompilerType = ct;
VisualEnvironmentCompiler.StandartCompiler.InternalDebug.CodeGeneration = true;
}
public void ExecuteOptions()
{
TextFormatterForm.ShowDialog();
}
public LanguageConverter_VisualPascalABCPlugin(IWorkbench Workbench)
{
Languages = LoadLanguages();
currentLanguage = Languages[0];
this.VisualEnvironmentCompiler = Workbench.VisualEnvironmentCompiler;
//TextFormatter = new TextFormatter();
TextFormatterForm = new TextFormatterForm();
TextFormatterForm.Plugin = this;
TextFormatterForm.Init();
VisualEnvironmentCompiler.StandartCompiler.OnChangeCompilerState += new PascalABCCompiler.ChangeCompilerStateEventDelegate(Compiler_OnChangeCompilerState);
}
public void ConvertSourceText()
{
try
{
PascalABCCompiler.SemanticTree.IProgramNode Root = VisualEnvironmentCompiler.StandartCompiler.SemanticTree;
//SemanticNodeConverter semanticNodeConverter = new SemanticNodeConverter(new ListSyntRules(
// System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName) + "\\Rules_CS.txt"), TextFormatter/*new TextFormatter()*/);
//TextFormatterForm.TextFormatter=new TextFormatter();
//TextFormatterForm.SaveTextFormater(currentLanguage.SourceTextBuilder.TextFormatter);
//currentLanguage.SourceTextBuilder.TextFormatter = TextFormatterForm.TextFormatter;
TextFormatterForm.SaveTextFormater(currentLanguage.SourceTextBuilder.TextFormatter);
SemanticTreeVisitor Visitor = new SemanticTreeVisitor(currentLanguage);//new SemanticNodeConverter(new ListSyntRules("Rules_CS.txt"), new TextFormatter()));
Root.visit(Visitor);
//ConvertTextViewer.Text = Visitor.GetConvertedText();
OpenFilesInEnvironment(Visitor.nmspaceFiles);
}
catch (NotSupportedException e)
{
System.Windows.Forms.MessageBox.Show(string.Format("Èçâèíèòå, ãåíåðàöèÿ êîäà äëÿ óçëà {0} íå ïîääåðæèâàåòñÿ. Òåêñò íå áûë ñãåíåðèðîâàí.", e.Message));
}
catch (Exception e)
{
VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.AddTextToCompilerMessages, "LanguageConverter Exception: " + e.ToString());
}
}
bool MyCompilation = false;
void Compiler_OnChangeCompilerState(PascalABCCompiler.ICompiler sender, PascalABCCompiler.CompilerState State, string FileName)
{
if (!MyCompilation) return;
switch (State)
{
case PascalABCCompiler.CompilerState.CompilationStarting:
//this.Refresh();
break;
case PascalABCCompiler.CompilerState.CompilationFinished:
ConvertSourceText();
MyCompilation = false;
break;
}
}
// ñòûðåíî
private List<ISemanticNodeConverter> LoadLanguages()
{
List<ISemanticNodeConverter> Langs = new List<ISemanticNodeConverter>();
// äèðåêòîðèÿ ýòîãî ïëàãèíà
string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName);
DirectoryInfo di = new DirectoryInfo(dir);
FileInfo[] dllfiles = di.GetFiles("*LanguageConverter.dll");
System.Reflection.Assembly asssembly = null;
Type constr = null;
ISemanticNodeConverter pc = null;
foreach (FileInfo fi in dllfiles)
{
asssembly = System.Reflection.Assembly.LoadFile(fi.FullName);
try
{
if (asssembly != null && asssembly.FullName != System.Reflection.Assembly.GetExecutingAssembly().FullName)
{
Type[] types = asssembly.GetTypes();
foreach (Type type in types)
{
if (type.Name.IndexOf("SemanticNodeConverter") >= 0)
{
Object obj = Activator.CreateInstance(type);
if (obj is ISemanticNodeConverter)
{
Langs.Add(obj as ISemanticNodeConverter);
}
}
}
}
}
catch (Exception e)
{
}
}
return Langs;
}
public void GetGUI(List<IPluginGUIItem> MenuItems, List<IPluginGUIItem> ToolBarItems)
{
PluginGUIItem Item = new PluginGUIItem(StringsPrefix + "BUILD", StringsPrefix + "BUILD", TextFormatterForm.ImageBuild.Image, TextFormatterForm.ImageBuild.BackColor, ExecuteBuild);
MenuItems.Add(Item);
ToolBarItems.Add(Item);
Item = new PluginGUIItem(StringsPrefix + "OPTIONS", StringsPrefix + "OPTIONS", TextFormatterForm.ImageOptions.Image, TextFormatterForm.ImageOptions.BackColor, ExecuteOptions);
MenuItems.Add(Item);
ToolBarItems.Add(Item);
}
}
}

View file

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Converter
{
public class ListSyntRules
{
// õðàíèò ñîîòâåòñòâèå ìåæäó óçëàìè ñåìàíòè÷åñêîãî äåðåâà ÐÀÂÑNET è ñîîòâåòñòâóþùèìè ñèíòàêñè÷åñêèìè ïðàâèëàìè äðóãîãî ÿçûêà
private Dictionary<string, string> Rules;
private string fileName;
private const string nodeSeparator = "@", ruleSeparator = "::";
public ListSyntRules(string _fileName)
{
fileName = _fileName;
initialisation();
}
public string GetRule(string _nodeName)
{
string result;
if (Rules.TryGetValue(_nodeName, out result))
{
return result;
}
else
return "";
}
public string[] GetWordsFromRule(string _node)
{
return GetRule(_node).Split(' ');
}
private void initialisation()
{
Rules = new Dictionary<string, string>();
initRules(readRulesTXTInToStr());
}
private string readRulesTXTInToStr()
{
TextReader readerTXT = File.OpenText(fileName);
return readerTXT.ReadToEnd();
}
private void initRules(string _rulesTXT)
{
string[] nameNodeAndRule;
string[] nodes;
string[] nodeSeparators = new string[1], ruleSeparators = new string[1];
nodeSeparators[0] = nodeSeparator;
ruleSeparators[0] = ruleSeparator;
nodes = _rulesTXT.Split(nodeSeparators, StringSplitOptions.RemoveEmptyEntries);
foreach (string node in nodes)
{
nameNodeAndRule = node.Split(ruleSeparators, StringSplitOptions.RemoveEmptyEntries);
nameNodeAndRule[0] = nameNodeAndRule[0].Replace(" ", "");
Rules.Add(nameNodeAndRule[0], nameNodeAndRule[1]);
}
}
}
}

View file

@ -0,0 +1,183 @@
@namespace ::
$namespace name *BlockBegin *BlockBody
${ *BlockBegin *BlockBody *BlockBody
$public $class name *BlockBegin *BlockBody
${ *BlockBegin
body
*BlockEnd *BlockBody $}
*BlockEnd *BlockBody $}
@class ::
access_modifier_type $class name *BlockBegin *BlockBody
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@struct ::
access_modifier_type $struct name *BlockBegin *BlockBody
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@function ::
$public $static type name $( parameters $) *BlockBegin *BlockBody
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@return ::
$return expr
@array_indexing ::
expr $[ expr $]
@function_call ::
name $( parameters $)
@comp_method_call ::
obj_name $. name $( parameters $)
@comp_stat_method_call ::
name $( parameters $)
@comm_stat_method_call ::
type $. name $( parameters $)
@type_of ::
$typeof $( type $)
@if ::
$if $( parameters $)
*BlockBegin *BlockBody
${
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@for ::
$for $( body $)
*BlockBegin *BlockBody
${
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@while ::
$while $( body $)
*BlockBegin *BlockBody
${
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@repeat ::
$do
*BlockBegin *BlockBody
${
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
$while $( parameters $)
@namespace_var ::
$public $static type name
@var ::
type name
@var_init ::
type name $= body
@const ::
$public $const type name
@statements ::
body
@statements_nested :: *BlockBegin *BlockBody
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@binop_assign ::
expr $= expr
@binop_add ::
expr $+ expr
@binop_subtract ::
expr $- expr
@binop_mult ::
expr $* expr
@binop_div ::
expr $/ expr
@unop_plus ::
$+ expr
@unop_minus ::
$- expr
@binop_mod ::
expr $% expr
@binop_eq ::
expr $== expr
@binop_gr ::
expr $> expr
@binop_sm ::
expr $< expr
@binop_greq ::
expr $>= expr
@binop_smeq ::
expr $<= expr
@binop_and ::
expr $&& expr
@binop_or ::
expr $|| expr
@binop_xor ::
expr $^ expr
@unop_inc ::
$++ expr
@unop_dec ::
$-- expr
@unop_unmin ::
$- $( expr $)
@unop_not ::
$not expr
@binop_shl ::
expr $<< expr
@binop_shr ::
expr $>> expr

View file

@ -0,0 +1,9 @@
using System;
using System.Collections.Generic;
using System.Text;
using PascalABCCompiler.SemanticTree;
namespace Converter
{
}

View file

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Converter
{
public class SourceTextBilder
{
public ListSyntRules ListSyntRules;
public TextFormatter TextFormatter;
private StringBuilder sourceString = new StringBuilder("");
private StringBuilder sourceStringNode = new StringBuilder("");
private StringBuilder sourceStringNodeBlock = new StringBuilder("");
private Stack<string> nodeStringStack = new Stack<string>();
public Dictionary<string, string> namespacesStr = new Dictionary<string,string>();
public SourceTextBilder()
{
TextFormatter = new TextFormatter();
// todo
ListSyntRules = new ListSyntRules(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName) + "\\Rules_CS.txt");
TextFormatter.GetBodyBlock += getBodyBlock;
}
public SourceTextBilder(ListSyntRules _listSyntRules, TextFormatter _textFormatter)
{
ListSyntRules = _listSyntRules;
TextFormatter = _textFormatter;
TextFormatter.GetBodyBlock += getBodyBlock;
}
private bool isEmptyString(string res)
{
// состоит ли строка только из пробелов
for (int i = 0; i < res.Length; i++)
{
if (!(res[i] == ' ' || res[i] == '\r' || res[i] == '\n'))
return false;
}
return true;
}
private string getBodyBlock()
{
string res = "";
while (isEmptyString(res) && (nodeStringStack.Count != 0))
//if ((nodeStringStack.Count != 0))
{
res = nodeStringStack.Pop();
}
if (res == "%empty%")
res = "";
return res;
}
private void addNodeInToString(StringBuilder _string, string _nodeName, object _node)
{
_string.Append(TextFormatter.Indents.BlockBody);
_string.Append(TextFormatter.FormatRuleNode(ListSyntRules.GetRule(_nodeName), _node));
_string.Append(Environment.NewLine);
}
public void AddNodeInToStack(string _node)
{
nodeStringStack.Push(_node);
}
public string GetNodeFromStack()
{
if (nodeStringStack.Count != 0)
return nodeStringStack.Pop();
else
return "";
}
public string ConvertNode (string _nodeName, object _node)
{
//addNodeInToString(sourceString, _nodeName, _node);
return TextFormatter.FormatRuleNode(ListSyntRules.GetRule(_nodeName), _node);
}
public void AddInToSourceText(string _text)
{
sourceString.Append(_text);
}
}
}

View file

@ -0,0 +1,420 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using PascalABCCompiler.SemanticTree;
using System.Text.RegularExpressions;
namespace Converter
{
public class TextFormatter
{
private Dictionary<string, getFieldValueFromSemanticNode> FieldValuesFromSemanticNode = new Dictionary<string, getFieldValueFromSemanticNode>();
private List<string> SpecSymbols = new List<string>();
private delegate string getFieldValueFromSemanticNode(object node);
public delegate string convertKeyWord(string _nameKeyWord, string _factVaulekeyWord);
public delegate string getBodyBlock();
public convertKeyWord ConvertKeyWord;
public getBodyBlock GetBodyBlock;
public IndentValues Indents = new IndentValues();
public struct IndentValues
{
private Dictionary<string, string> indents;
private string blockBodyInSourceText;
private string blockBody;
public void init()
{
indents = new Dictionary<string, string>();
indents.Add(IndentNames.BlockBegin, Environment.NewLine);
indents.Add(IndentNames.BlockEnd, Environment.NewLine);
indents.Add(IndentNames.BlockBody, " ");
indents.Add(IndentNames.BetweenWords, " ");
blockBody = indents[IndentNames.BlockBody];
blockBodyInSourceText = indents[IndentNames.BlockBody];
}
public string BlockBodyIncrement()
{
return indents[IndentNames.BlockBody] += blockBody;
}
public string BlockBodyDecrement()
{
return indents[IndentNames.BlockBody] = indents[IndentNames.BlockBody].Remove(indents[IndentNames.BlockBody].Length - blockBody.Length);
}
public string BlockBodyInSourceText
{
get
{
return blockBodyInSourceText;
}
}
public string BlockBegin
{
set
{
indents[IndentNames.BlockBegin] = value;
}
get
{
return indents[IndentNames.BlockBegin];
}
}
public string BlockEnd
{
set
{
indents[IndentNames.BlockEnd] = value;
}
get
{
return indents[IndentNames.BlockEnd];
}
}
public string BlockBody
{
set
{
blockBody = value;
indents[IndentNames.BlockBody] = value;
}
get
{
return indents[IndentNames.BlockBody];
}
}
public string BetweenWords
{
set
{
indents[IndentNames.BetweenWords] = value;
}
get
{
return indents[IndentNames.BetweenWords];
}
}
public string GetIndent(string _indentName)
{
if (indents.ContainsKey(_indentName))
return indents[_indentName];
return "";
}
}
public struct IndentNames
{
public static string BlockBegin = "BlockBegin";
public static string BlockEnd = "BlockEnd";
public static string BlockBody = "BlockBody";
public static string BetweenWords = "BW";
}
public struct SpecSymbValues
{
public static string KeyWord = "$";
public static string Indent = "*";
}
public struct SemanticNodeFields
{
public static string Body = "body";
public static string Expr = "expr";
public static string ObjName = "obj_name";
public static string Parameters = "parameters";
public static string Name = "name";
public static string Type = "type";
public static string Value = "value";
public static string AccessModifierField = "access_modifier_field";
public static string AccessModifierType = "access_modifier_type";
}
public TextFormatter()
{
init();
}
private void init()
{
Indents.init();
specSymbolsInit();
semanticNodeFieldsMethodsInit();
}
private void specSymbolsInit()
{
SpecSymbols.Add(SpecSymbValues.KeyWord);
SpecSymbols.Add(SpecSymbValues.Indent);
}
private void semanticNodeFieldsMethodsInit()
{
FieldValuesFromSemanticNode.Add(SemanticNodeFields.Name, getFieldValueFromSemanticNodeName);
FieldValuesFromSemanticNode.Add(SemanticNodeFields.Type, getFieldValueFromSemanticNodeType);
FieldValuesFromSemanticNode.Add(SemanticNodeFields.AccessModifierField, getFieldValueFromSemanticNodeAccessModifierField);
FieldValuesFromSemanticNode.Add(SemanticNodeFields.AccessModifierType, getFieldValueFromSemanticNodeAccessModifierType);
}
// методы, возвращающие фактическое значение соответствующего поля для данного узла
#region
// вот они:
private string getFieldValueFromSemanticNodeName(object _node)
{
if (_node is ICommonNamespaceNode)
{
string name = (_node as ICommonNamespaceNode).namespace_name;
if (name == "")
// Задавать пользователем дефолтное имя главного неймспейса!!!
name = "Program";
return name;
}
if (_node is ILocalVariableReferenceNode)
return (_node as ILocalVariableReferenceNode).Variable.name;
if (_node is INamespaceVariableReferenceNode)
return (_node as INamespaceVariableReferenceNode).Variable.name;
if (_node is ILocalBlockVariableReferenceNode)
return (_node as ILocalBlockVariableReferenceNode).Variable.name;
if (_node is ICompiledStaticMethodCallNode)
return (_node as ICompiledStaticMethodCallNode).compiled_type.compiled_type.ToString() + "." + (_node as ICompiledStaticMethodCallNode).static_method.name;
if (_node is ICompiledMethodCallNode)
return (_node as ICompiledMethodCallNode).compiled_method.name;
if (_node is ITypeNode)
return (_node as ITypeNode).name;
if (_node is ITypeSynonym)
return (_node as ITypeSynonym).name;
if (_node is IFunctionNode)
return (_node as IFunctionNode).name;
if (_node is ICommonNamespaceFunctionCallNode)
return (_node as ICommonNamespaceFunctionCallNode).function.name;
if (_node is IExternalStatementNode)
return (_node as IExternalStatementNode).name;
if (_node is IVAriableDefinitionNode)
return (_node as IVAriableDefinitionNode).name;
if (_node is IConstantDefinitionNode)
return (_node as IConstantDefinitionNode).name;
if (_node is IPropertyNode)
return (_node as IPropertyNode).name;
if (_node is ILabelNode)
return (_node as ILabelNode).name;
return "";
}
private string getType(object _node)
{
if (_node is ICompiledTypeNode)
return (_node as ICompiledTypeNode).compiled_type.ToString();
if (_node is ICommonTypeNode)
if ((_node as ICommonTypeNode).comprehensive_namespace.namespace_name != "")
return (_node as ICommonTypeNode).comprehensive_namespace.namespace_name + "." + (_node as ICommonTypeNode).name;
else
return (_node as ICommonTypeNode).name;
return "";
}
private string getFieldValueFromSemanticNodeType(object _node)
{
if (_node is ICommonNamespaceFunctionNode)
{// TODO: сделать определения для разных языков нормальное
if ((_node as ICommonNamespaceFunctionNode).return_value_type == null)
return "void";
else
return getType((_node as ICommonNamespaceFunctionNode).return_value_type);
}
if (_node is ITypeOfOperator)
return getType((_node as ITypeOfOperator).oftype);
if (_node is ICommonConstructorCall)
return getType((_node as ICommonConstructorCall).common_type);
if (_node is ICompiledTypeNode)
return (_node as ICompiledTypeNode).compiled_type.ToString();
if (_node is IExpressionNode)
return getType((_node as IExpressionNode).type);
if (_node is IVAriableDefinitionNode)
return getType((_node as IVAriableDefinitionNode).type);
if (_node is IConstantDefinitionNode)
return getType((_node as IConstantDefinitionNode).type);
return "";
}
private string getFieldValueFromSemanticNodeAccessModifierField(object _node)
{
//fal_private, fal_internal, fal_protected, fal_public
if (_node is IClassMemberNode)
{
//поместить в класс семант. правил структуру с их строковыми значениями
IClassMemberNode node = _node as IClassMemberNode;
if ((node).field_access_level == field_access_level.fal_internal)
return "internal" + Indents.BetweenWords;
if ((node).field_access_level == field_access_level.fal_private)
return "private" + Indents.BetweenWords;
if ((node).field_access_level == field_access_level.fal_protected)
return "protected" + Indents.BetweenWords;
if ((node).field_access_level == field_access_level.fal_public)
return "public" + Indents.BetweenWords;
}
return "";
}
private string getFieldValueFromSemanticNodeAccessModifierType(object _node)
{
// структуру в абстр. класс для хранения соотв. значений в Сишарпе (и других языках)
string fieldValue = "";
if (_node is ICommonTypeNode)
{
ICommonTypeNode node = _node as ICommonTypeNode;
if ((node).type_access_level == type_access_level.tal_internal)
return "internal" + Indents.BetweenWords;
if ((node).type_access_level == type_access_level.tal_public)
return "public" + Indents.BetweenWords;
}
return "";
}
#endregion
private string getWordValue(string _word, string _specSymb)
{
if (_specSymb == SpecSymbValues.KeyWord)
return _word;
if (_specSymb == SpecSymbValues.Indent)
return Indents.GetIndent(_word);
return "";
}
public string FormatWord(string _word, object _node)
{
// cltkfnm yjhvfkmyj
if (_word != "")
{
_word = _word.Replace(" ", "");
_word = _word.Replace("\r", "");
_word = _word.Replace("\n", "");
}
else return _word;
foreach (string specSymbol in this.SpecSymbols)
{
if (_word.Contains(specSymbol))
{
_word = _word.Replace(specSymbol, "");
return getWordValue(_word, specSymbol);
}
}
if (_word == SemanticNodeFields.Body || _word == SemanticNodeFields.Expr || _word == SemanticNodeFields.Parameters || _word == SemanticNodeFields.ObjName)
{
if (GetBodyBlock != null)
return GetBodyBlock();
}
if (FieldValuesFromSemanticNode.ContainsKey(_word))
{
string word = FieldValuesFromSemanticNode[_word](_node);
return replSymb(word);
}
return _word;
}
private string replSymb(string _word)
{
_word = _word.Replace("$", "S");
return _word;
}
private string deleteSymbolsFromWord(string _word)
{
// переделать этот ужас!!!
_word = _word.Replace("$", "");
_word = _word.Replace("#", "");
return _word;
}
// если привязан спец. обработчик для ключ. слов - вызывается, иначе возвр. точное значение, как в PABCNET
public string FormatWordWithKeyWord(string _word, object _node)
{
if (_word != "")
{
_word = _word.Replace(" ", "");
_word = _word.Replace("\r", "");
_word = _word.Replace("\n", "");
}
else return _word;
foreach (string specSymbol in this.SpecSymbols)
{
if (_word.Contains(specSymbol))
{
_word.Replace(specSymbol, "");
return getWordValue(_word, specSymbol);
}
else
{
if (ConvertKeyWord != null)
return ConvertKeyWord(_word, FieldValuesFromSemanticNode[_word](_node));
else
return FieldValuesFromSemanticNode[_word](_node);
}
}
return _word;
}
// значения, соответствующие ключевым словам в PABCNET, преобразуются методом, привязанным к делегату
public string FormatRuleNodeWithKeyWord(string _ruleNode, object _node)
{
StringBuilder nodeString = new StringBuilder("");
string[] ruleNode = _ruleNode.Split(' ');
foreach (string nodeWord in ruleNode)
nodeString.Append(this.FormatWordWithKeyWord(nodeWord, _node));
return nodeString.ToString();
}
// для языков, у которых значения спецификаторов(?) строго совпадают с соответствующими в PascalABCNET
public string FormatRuleNode(string _ruleNode, object _node)
{
StringBuilder nodeString = new StringBuilder("");
string[] ruleNode = _ruleNode.Split(' ');
foreach (string nodeWord in ruleNode)
nodeString.Append(this.FormatWord(nodeWord, _node));
return nodeString.ToString();
}
}
}

View file

@ -0,0 +1,310 @@
namespace Converter
{
partial class TextFormatterForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TextFormatterForm));
this.comboBoxBlockBegin = new System.Windows.Forms.ComboBox();
this.comboBoxBlockEnd = new System.Windows.Forms.ComboBox();
this.labelBlockBegin = new System.Windows.Forms.Label();
this.labelBlockEnd = new System.Windows.Forms.Label();
this.labelBlockBodySymb = new System.Windows.Forms.Label();
this.labelBetweenWordsSymb = new System.Windows.Forms.Label();
this.buttonOk = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.comboBoxBodyBlock = new System.Windows.Forms.ComboBox();
this.comboBoxBetweenWords = new System.Windows.Forms.ComboBox();
this.labelBlockBodyCount = new System.Windows.Forms.Label();
this.labelBetweenWordsCount = new System.Windows.Forms.Label();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.cbLanguage = new System.Windows.Forms.ComboBox();
this.ImageOptions = new System.Windows.Forms.PictureBox();
this.ImageBuild = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.ImageOptions)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.ImageBuild)).BeginInit();
this.SuspendLayout();
//
// comboBoxBlockBegin
//
this.comboBoxBlockBegin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxBlockBegin.FormattingEnabled = true;
this.comboBoxBlockBegin.Items.AddRange(new object[] {
"C новой строки",
"C текущей строки"});
this.comboBoxBlockBegin.Location = new System.Drawing.Point(177, 33);
this.comboBoxBlockBegin.Name = "comboBoxBlockBegin";
this.comboBoxBlockBegin.Size = new System.Drawing.Size(283, 21);
this.comboBoxBlockBegin.TabIndex = 3;
//
// comboBoxBlockEnd
//
this.comboBoxBlockEnd.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxBlockEnd.FormattingEnabled = true;
this.comboBoxBlockEnd.Items.AddRange(new object[] {
"C новой строки",
"C текущей строки"});
this.comboBoxBlockEnd.Location = new System.Drawing.Point(177, 60);
this.comboBoxBlockEnd.Name = "comboBoxBlockEnd";
this.comboBoxBlockEnd.Size = new System.Drawing.Size(283, 21);
this.comboBoxBlockEnd.TabIndex = 4;
//
// labelBlockBegin
//
this.labelBlockBegin.AutoSize = true;
this.labelBlockBegin.Location = new System.Drawing.Point(12, 33);
this.labelBlockBegin.Name = "labelBlockBegin";
this.labelBlockBegin.Size = new System.Drawing.Size(77, 13);
this.labelBlockBegin.TabIndex = 5;
this.labelBlockBegin.Text = "Начало блока";
//
// labelBlockEnd
//
this.labelBlockEnd.AutoSize = true;
this.labelBlockEnd.Location = new System.Drawing.Point(12, 60);
this.labelBlockEnd.Name = "labelBlockEnd";
this.labelBlockEnd.Size = new System.Drawing.Size(71, 13);
this.labelBlockEnd.TabIndex = 6;
this.labelBlockEnd.Text = "Конец блока";
//
// labelBlockBodySymb
//
this.labelBlockBodySymb.AutoSize = true;
this.labelBlockBodySymb.Location = new System.Drawing.Point(12, 92);
this.labelBlockBodySymb.Name = "labelBlockBodySymb";
this.labelBlockBodySymb.Size = new System.Drawing.Size(110, 13);
this.labelBlockBodySymb.TabIndex = 7;
this.labelBlockBodySymb.Text = "Отступ в теле блока";
this.labelBlockBodySymb.Click += new System.EventHandler(this.labelBlockBody_Click);
//
// labelBetweenWordsSymb
//
this.labelBetweenWordsSymb.AutoSize = true;
this.labelBetweenWordsSymb.Location = new System.Drawing.Point(12, 117);
this.labelBetweenWordsSymb.Name = "labelBetweenWordsSymb";
this.labelBetweenWordsSymb.Size = new System.Drawing.Size(125, 13);
this.labelBetweenWordsSymb.TabIndex = 8;
this.labelBetweenWordsSymb.Text = "Отступ между словами";
//
// buttonOk
//
this.buttonOk.Location = new System.Drawing.Point(304, 150);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(75, 23);
this.buttonOk.TabIndex = 9;
this.buttonOk.Text = "Ok";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
//
// buttonCancel
//
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(385, 150);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 10;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// comboBoxBodyBlock
//
this.comboBoxBodyBlock.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxBodyBlock.FormattingEnabled = true;
this.comboBoxBodyBlock.Items.AddRange(new object[] {
"Пробел"});
this.comboBoxBodyBlock.Location = new System.Drawing.Point(177, 87);
this.comboBoxBodyBlock.Name = "comboBoxBodyBlock";
this.comboBoxBodyBlock.Size = new System.Drawing.Size(121, 21);
this.comboBoxBodyBlock.TabIndex = 11;
//
// comboBoxBetweenWords
//
this.comboBoxBetweenWords.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxBetweenWords.FormattingEnabled = true;
this.comboBoxBetweenWords.Items.AddRange(new object[] {
"Пробел"});
this.comboBoxBetweenWords.Location = new System.Drawing.Point(177, 114);
this.comboBoxBetweenWords.Name = "comboBoxBetweenWords";
this.comboBoxBetweenWords.Size = new System.Drawing.Size(121, 21);
this.comboBoxBetweenWords.TabIndex = 12;
this.comboBoxBetweenWords.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
//
// labelBlockBodyCount
//
this.labelBlockBodyCount.AutoSize = true;
this.labelBlockBodyCount.Location = new System.Drawing.Point(313, 94);
this.labelBlockBodyCount.Name = "labelBlockBodyCount";
this.labelBlockBodyCount.Size = new System.Drawing.Size(66, 13);
this.labelBlockBodyCount.TabIndex = 13;
this.labelBlockBodyCount.Text = "Количество";
//
// labelBetweenWordsCount
//
this.labelBetweenWordsCount.AutoSize = true;
this.labelBetweenWordsCount.Location = new System.Drawing.Point(313, 122);
this.labelBetweenWordsCount.Name = "labelBetweenWordsCount";
this.labelBetweenWordsCount.Size = new System.Drawing.Size(66, 13);
this.labelBetweenWordsCount.TabIndex = 14;
this.labelBetweenWordsCount.Text = "Количество";
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(395, 87);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(65, 20);
this.numericUpDown1.TabIndex = 15;
this.numericUpDown1.Value = new decimal(new int[] {
4,
0,
0,
0});
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// numericUpDown2
//
this.numericUpDown2.Location = new System.Drawing.Point(395, 115);
this.numericUpDown2.Name = "numericUpDown2";
this.numericUpDown2.Size = new System.Drawing.Size(65, 20);
this.numericUpDown2.TabIndex = 16;
this.numericUpDown2.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 17;
this.label1.Text = "Язык";
//
// cbLanguage
//
this.cbLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbLanguage.FormattingEnabled = true;
this.cbLanguage.Items.AddRange(new object[] {
"C новой строки",
"C текущей строки"});
this.cbLanguage.Location = new System.Drawing.Point(177, 6);
this.cbLanguage.Name = "cbLanguage";
this.cbLanguage.Size = new System.Drawing.Size(283, 21);
this.cbLanguage.TabIndex = 18;
this.cbLanguage.SelectedIndexChanged += new System.EventHandler(this.cbLanguage_SelectedIndexChanged);
//
// ImageOptions
//
this.ImageOptions.BackColor = System.Drawing.Color.Magenta;
this.ImageOptions.Image = ((System.Drawing.Image)(resources.GetObject("ImageOptions.Image")));
this.ImageOptions.Location = new System.Drawing.Point(88, 150);
this.ImageOptions.Name = "ImageOptions";
this.ImageOptions.Size = new System.Drawing.Size(16, 16);
this.ImageOptions.TabIndex = 19;
this.ImageOptions.TabStop = false;
this.ImageOptions.Visible = false;
//
// ImageBuild
//
this.ImageBuild.BackColor = System.Drawing.Color.Magenta;
this.ImageBuild.Image = ((System.Drawing.Image)(resources.GetObject("ImageBuild.Image")));
this.ImageBuild.Location = new System.Drawing.Point(110, 150);
this.ImageBuild.Name = "ImageBuild";
this.ImageBuild.Size = new System.Drawing.Size(16, 16);
this.ImageBuild.TabIndex = 20;
this.ImageBuild.TabStop = false;
this.ImageBuild.Visible = false;
//
// TextFormatterForm
//
this.AcceptButton = this.buttonOk;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(475, 184);
this.Controls.Add(this.ImageBuild);
this.Controls.Add(this.ImageOptions);
this.Controls.Add(this.cbLanguage);
this.Controls.Add(this.label1);
this.Controls.Add(this.numericUpDown2);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.labelBetweenWordsCount);
this.Controls.Add(this.labelBlockBodyCount);
this.Controls.Add(this.comboBoxBetweenWords);
this.Controls.Add(this.comboBoxBodyBlock);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.labelBetweenWordsSymb);
this.Controls.Add(this.labelBlockBodySymb);
this.Controls.Add(this.labelBlockEnd);
this.Controls.Add(this.labelBlockBegin);
this.Controls.Add(this.comboBoxBlockEnd);
this.Controls.Add(this.comboBoxBlockBegin);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "TextFormatterForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Форматирование";
this.Shown += new System.EventHandler(this.TextFormatterForm_Shown);
this.Load += new System.EventHandler(this.TextFormatterForm_Load);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ImageOptions)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ImageBuild)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox comboBoxBlockBegin;
private System.Windows.Forms.ComboBox comboBoxBlockEnd;
private System.Windows.Forms.Label labelBlockBegin;
private System.Windows.Forms.Label labelBlockEnd;
private System.Windows.Forms.Label labelBlockBodySymb;
private System.Windows.Forms.Label labelBetweenWordsSymb;
private System.Windows.Forms.Button buttonOk;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.ComboBox comboBoxBodyBlock;
private System.Windows.Forms.ComboBox comboBoxBetweenWords;
private System.Windows.Forms.Label labelBlockBodyCount;
private System.Windows.Forms.Label labelBetweenWordsCount;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.NumericUpDown numericUpDown2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox cbLanguage;
public System.Windows.Forms.PictureBox ImageOptions;
public System.Windows.Forms.PictureBox ImageBuild;
}
}

View file

@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using VisualPascalABCPlugins;
namespace Converter
{
public partial class TextFormatterForm : Form
{
public TextFormatter TextFormatter;
internal LanguageConverter_VisualPascalABCPlugin Plugin;
private Dictionary<string, string> indentsBlockBegin;
private Dictionary<string, string> indentsBlockEnd;
private Dictionary<string, string> indentsBodyBlock;
private Dictionary<string, string> indentsBetweenWords;
public TextFormatterForm(TextFormatter _textFormatter)
{
InitializeComponent();
TextFormatter = _textFormatter;
initIndents();
}
public TextFormatterForm()
{
InitializeComponent();
//TextFormatter = new TextFormatter();
initIndents();
}
private void initIndents()
{
indentsBlockBegin = new Dictionary<string, string>();
indentsBlockBegin.Add(comboBoxBlockBegin.Items[0].ToString(), Environment.NewLine);
indentsBlockBegin.Add(comboBoxBlockBegin.Items[1].ToString(), "");
indentsBlockEnd = new Dictionary<string, string>();
indentsBlockEnd.Add(comboBoxBlockEnd.Items[0].ToString(), Environment.NewLine);
indentsBlockEnd.Add(comboBoxBlockEnd.Items[1].ToString(), "");
indentsBodyBlock = new Dictionary<string, string>();
indentsBodyBlock.Add(comboBoxBodyBlock.Items[0].ToString(), " ");
indentsBetweenWords = new Dictionary<string, string>();
indentsBetweenWords.Add(comboBoxBetweenWords.Items[0].ToString(), " ");
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void labelBlockBody_Click(object sender, EventArgs e)
{
}
private void TextFormatterForm_Shown(object sender, EventArgs e)
{
}
public void SaveTextFormater(TextFormatter _TextFormatter)
{
_TextFormatter.Indents.BlockBegin = indentsBlockBegin[comboBoxBlockBegin.SelectedItem.ToString()];
_TextFormatter.Indents.BlockEnd = indentsBlockEnd[comboBoxBlockEnd.SelectedItem.ToString()];
StringBuilder bodyBlock = new StringBuilder();
for (int i = 0; i < numericUpDown1.Value; i++)
bodyBlock.Append(indentsBodyBlock[comboBoxBodyBlock.SelectedItem.ToString()]);
_TextFormatter.Indents.BlockBody = bodyBlock.ToString();
_TextFormatter.Indents.BetweenWords = indentsBetweenWords[comboBoxBetweenWords.SelectedItem.ToString()];
}
private void buttonOk_Click(object sender, EventArgs e)
{
SaveTextFormater(Plugin.Languages[cbLanguage.SelectedIndex].SourceTextBuilder.TextFormatter);
this.Close();
}
private void cbLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
Plugin.currentLanguage = Plugin.Languages[cbLanguage.SelectedIndex];
}
internal void Init()
{
cbLanguage.Items.Clear();
foreach (ISemanticNodeConverter snc in Plugin.Languages)
{
cbLanguage.Items.Add(snc.ToString());
}
comboBoxBlockBegin.SelectedItem = comboBoxBlockBegin.Items[0];
comboBoxBlockEnd.SelectedItem = comboBoxBlockEnd.Items[0];
comboBoxBodyBlock.SelectedItem = comboBoxBodyBlock.Items[0];
comboBoxBetweenWords.SelectedItem = comboBoxBetweenWords.Items[0];
cbLanguage.SelectedIndex = Plugin.Languages.IndexOf(Plugin.currentLanguage);
}
private void TextFormatterForm_Load(object sender, EventArgs e)
{
}
}
}

View file

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="ImageOptions.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAo9JREFUOE99k+1L
U1Ecx69/TQSBL3ogwRe9Ed9bm0iS5VCw9qDTMRIcKjifWjVLE50aKDoxKxNmQ4MlU9JQWlIT57Smqc3N
OXXN3XvP/Xbu8dlFB36ccy/n+/l+z+/ek/Jxah6CQDheJJxISzgsec2KEI4Qib2X17q7mSnc6THm/ob/
DSJJoAAIogSDuUPeyp0uzuH6+k891UEWi1TICxIi0Rh0lS+SAUOjswxw4+E60vQ/cVntgyQLD10TVBxP
SAiGdlBU3pQMGHR8PkkguxKciHkq3ifYixOsrm8hv8ySDLAPf2IAOXKaPkATLCC1wINLeZO4mOPEhaxB
RGMilgJBaCqeJQO6X0+wyISeVaBxE7JrgiBGXXepcHtPxNaOgHn/GozmtmRA58A467B81rQS2oMHPqQW
eqAweeCY3EC7zY/uvgBm5lZQbppFqf7DGQjX3udi4jhPXfdF7P4hiMquuwJCUQH9vavo7PLBVP2FAYp1
zrOAlp4xFnkvLotFXKEJRqYjaGxdQn2jF46RGOz9YZjr/TBWfIdGPQ693nWchGt66TxwpeeNUNcwdQ1G
BDx+6kdvzy/Y7duorprF7dwu6EpsDJCtHMK1qxqWhLPYHMeNuk6/gub5Kt5MhPHOvQlz7RwsT35AqeyA
e8oLtaEFWu0MAxz9jVx96zDCtMvBbR4bWwmshXgEggkqXoTR4GKzVvuK9qAfpcZhqFRuBjiCcDXNb/E7
wsO/sgnv4jo83gCmPctQZLciI6MS97Uu3Lk3CmWeE7riBQbIL7CdHKHKOgiV4RFydbVQFlVDVdYArakJ
5XVtsNoGkJFZh8L8IaSnF+NmVjObz1ym87fr/HN2jhW3FAd3oKbhPYOc3vMXoHgYXvXB+nwAAAAASUVO
RK5CYII=
</value>
</data>
<data name="ImageBuild.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAo9JREFUOE99k+1L
U1Ecx69/TQSBL3ogwRe9Ed9bm0iS5VCw9qDTMRIcKjifWjVLE50aKDoxKxNmQ4MlU9JQWlIT57Smqc3N
OXXN3XvP/Xbu8dlFB36ccy/n+/l+z+/ek/Jxah6CQDheJJxISzgsec2KEI4Qib2X17q7mSnc6THm/ob/
DSJJoAAIogSDuUPeyp0uzuH6+k891UEWi1TICxIi0Rh0lS+SAUOjswxw4+E60vQ/cVntgyQLD10TVBxP
SAiGdlBU3pQMGHR8PkkguxKciHkq3ifYixOsrm8hv8ySDLAPf2IAOXKaPkATLCC1wINLeZO4mOPEhaxB
RGMilgJBaCqeJQO6X0+wyISeVaBxE7JrgiBGXXepcHtPxNaOgHn/GozmtmRA58A467B81rQS2oMHPqQW
eqAweeCY3EC7zY/uvgBm5lZQbppFqf7DGQjX3udi4jhPXfdF7P4hiMquuwJCUQH9vavo7PLBVP2FAYp1
zrOAlp4xFnkvLotFXKEJRqYjaGxdQn2jF46RGOz9YZjr/TBWfIdGPQ693nWchGt66TxwpeeNUNcwdQ1G
BDx+6kdvzy/Y7duorprF7dwu6EpsDJCtHMK1qxqWhLPYHMeNuk6/gub5Kt5MhPHOvQlz7RwsT35AqeyA
e8oLtaEFWu0MAxz9jVx96zDCtMvBbR4bWwmshXgEggkqXoTR4GKzVvuK9qAfpcZhqFRuBjiCcDXNb/E7
wsO/sgnv4jo83gCmPctQZLciI6MS97Uu3Lk3CmWeE7riBQbIL7CdHKHKOgiV4RFydbVQFlVDVdYArakJ
5XVtsNoGkJFZh8L8IaSnF+NmVjObz1ym87fr/HN2jhW3FAd3oKbhPYOc3vMXoHgYXvXB+nwAAAAASUVO
RK5CYII=
</value>
</data>
</root>

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SCharpLanguageConverter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SCharpLanguageConverter")]
[assembly: AssemblyCopyright("Copyright © 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9a6d0570-77d4-4309-9a35-6d726c345a43")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8F44EF8C-C487-4D23-B028-55935466DC36}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SCharpLanguageConverter</RootNamespace>
<AssemblyName>SCharpLanguageConverter</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>4.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="SemanticTree, Version=0.10.1.222, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\bin\SemanticTree.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="SemanticNodeConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>Клиентский профиль .NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Установщик Windows 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LanguageConverter\LanguageConverter.csproj">
<Project>{43879684-ADBE-470A-AAC6-2ACA36603971}</Project>
<Name>LanguageConverter</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,398 @@
using System;
using System.Collections.Generic;
using System.Text;
using PascalABCCompiler.SemanticTree;
namespace Converter
{
public class CSharpSemanticNodeConverter : ISemanticNodeConverter
{
private SourceTextBilder sourceTextBuilder;
public SourceTextBilder SourceTextBuilder
{
set
{
sourceTextBuilder = value;
}
get
{
return sourceTextBuilder;
}
}
public CSharpSemanticNodeConverter()
{
SourceTextBuilder = new SourceTextBilder();
}
public CSharpSemanticNodeConverter(ListSyntRules _listSyntRules, TextFormatter _textFormatter)
{
SourceTextBuilder = new SourceTextBilder(_listSyntRules, _textFormatter);
}
public string GetConvertedText()
{
return SourceTextBuilder.GetNodeFromStack();
}
public virtual string ConvertPABCNETNodeProgram(string _nodeName, object _node)
{
// IProgramNode - îñíîâíîé óçåë, ñîäåðæèò âåñü òåêñò ïðîãðàììû,
// îáðàáàòûâàåòñÿ âèçèòîðîì ïîñëåäíèì.
return SourceTextBuilder.GetNodeFromStack();
}
public virtual string ConvertPABCNETNodeClass(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeNamespace(string _nodeName, object _node)
{
//SourceTextBuilder.TextFormatter.Indents.BlockBodyIncrement();
string nodeContext = SourceTextBuilder.ConvertNode(_nodeName, _node);
//SourceTextBuilder.TextFormatter.Indents.BlockBodyDecrement();
return nodeContext;
}
public virtual string ConvertPABCNETNodeBlock(string _nodeName, object _node)
{
return "";
}
public virtual string ConvertPABCNETNodeType(string _nodeName, object _node)
{
if ((_node as ICommonTypeNode).is_value_type)
return SourceTextBuilder.ConvertNode("struct", _node);
else // ñäåëàòü äëÿ øàáëîíîâ, ïàðàìåòðèçîâàííûõ ùàáëîíîâ, êëàññîâ.
return SourceTextBuilder.ConvertNode("class", _node);
}
public virtual string ConvertPABCNETNodeFunction(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeVariable(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeStatementsNested(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeStatements(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeAssign(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeVariableReference(string _nodeName, object _node)
{
// âîçâðàùàåì èìÿ ïåðåìåííîé
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeParameterReference(string _nodeName, object _node)
{
// âîçâðàùàåì èìÿ ïåðåìåííîé
return (_node as ICommonParameterReferenceNode).parameter.name;
}
public virtual string ConvertPABCNETNodeBoolConstant(string _nodeName, object _node)
{
// âîçâðàùàåì èìÿ ïåðåìåííîé
return (_node as IBoolConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeFunctionCall(string _nodeName, object _node)
{
// âîçâðàùàåì èìÿ ïåðåìåííîé
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeParameter(string _nodeName, object _node)
{
string type = "";
// âîçâðàùàåì èìÿ è òèï ïåðåìåííîé
if ((_node as ICommonParameterNode).type is ICompiledTypeNode)
type = ((_node as ICommonParameterNode).type as ICompiledTypeNode).compiled_type.ToString();
if ((_node as ICommonParameterNode).type is ICommonTypeNode)
type = ((_node as ICommonParameterNode).type as ICommonTypeNode).name;
return type + " " + (_node as ICommonParameterNode).name;
}
public virtual string ConvertPABCNETNodeNamespaceVariable(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeNamespaceConst(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeIf(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeLocalBlockVariable(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeStaticMethodCall(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeTypeOf(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeIntConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return (_node as IIntConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeByteConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return (_node as IByteConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeSByteConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return (_node as ISByteConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeShortConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return (_node as IShortConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeUShortConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return (_node as IUShortConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeUIntConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return (_node as IUIntConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeULongConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return (_node as IULongConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeLongConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return (_node as ILongConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeDoubleConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return (_node as IDoubleConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeFloatConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return (_node as IFloatConstantNode).constant_value.ToString();
}
public virtual string ConvertPABCNETNodeCharConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return "'" + (_node as ICharConstantNode).constant_value.ToString() + "'";
}
public virtual string ConvertPABCNETNodeStringConstant(string _nodeName, object _node)
{
// âîçâðàùàåì ÷èñëî integer
return "\"" + (_node as IStringConstantNode).constant_value.ToString() + "\"";
}
public virtual string ConvertPABCNETNodeWhile(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeRepeat(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeFor(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeSimpleArrInd(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeAdd(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeSubtract(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeMult(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeDiv(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeMod(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeInc(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeDec(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeBinNot(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeUnNot(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeShr(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeShl(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeReturn(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeEq(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeNotEq(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeGr(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeGrEq(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeSm(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeSmEq(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeAnd(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeOr(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeXor(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeUnMin(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeLocVariableReference(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeNullConst(string _nodeName, object _node)
{
return "null";
}
public virtual string ConvertPABCNETNodeConstructorCall(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeCompMethodCall(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeIfElse(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeUnInc(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public virtual string ConvertPABCNETNodeUnDec(string _nodeName, object _node)
{
return SourceTextBuilder.ConvertNode(_nodeName, _node);
}
public override string ToString()
{
return "C#";
}
}
}