diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index b27286217..027f296c6 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -3291,7 +3291,7 @@ namespace PascalABCCompiler private void SemanticCheckNoIncludeDirectivesInPascalUnit(CompilationUnit compilationUnit) { - if (HasIncludeNamespaceDirective(compilationUnit) && compilationUnit.SyntaxTree is SyntaxTree.unit_module unitModule + if (compilationUnit.SyntaxTree is SyntaxTree.unit_module unitModule && HasIncludeNamespaceDirective(compilationUnit) && unitModule.unit_name.HeaderKeyword != SyntaxTree.UnitHeaderKeyword.Library) { throw new IncludeNamespaceInUnitError(currentCompilationUnit.SyntaxTree.file_name, currentCompilationUnit.SyntaxTree.source_context); @@ -3584,15 +3584,19 @@ namespace PascalABCCompiler /// public static bool IsDll(SyntaxTree.compilation_unit unitSyntaxTree, out SyntaxTree.compiler_directive dllDirective) { - foreach (SyntaxTree.compiler_directive directive in unitSyntaxTree.compiler_directives) + if (unitSyntaxTree != null) { - if (string.Equals(directive.Name.text, "apptype", StringComparison.CurrentCultureIgnoreCase) - && string.Equals(directive.Directive.text, "dll", StringComparison.CurrentCultureIgnoreCase)) + foreach (SyntaxTree.compiler_directive directive in unitSyntaxTree.compiler_directives) { - dllDirective = directive; - return true; + if (string.Equals(directive.Name.text, "apptype", StringComparison.CurrentCultureIgnoreCase) + && string.Equals(directive.Directive.text, "dll", StringComparison.CurrentCultureIgnoreCase)) + { + dllDirective = directive; + return true; + } } } + dllDirective = null; return false; } diff --git a/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascal.cs b/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascal.cs index 071797877..5f1bb305c 100644 --- a/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascal.cs +++ b/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascal.cs @@ -2,7 +2,7 @@ // This CSharp output file generated by Gardens Point LEX // Version: 1.1.3.301 // Machine: DESKTOP-V3E9T2U -// DateTime: 19.05.2024 23:53:52 +// DateTime: 25.05.2024 22:13:44 // UserName: alex // GPLEX input file // GPLEX frame file diff --git a/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascal.y b/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascal.y index b4ddfccf0..ebc8d14d3 100644 --- a/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascal.y @@ -423,7 +423,8 @@ unit_file unit_header interface_part implementation_part initialization_part tkPoint { $$ = new unit_module($1 as unit_name, $2 as interface_node, $3 as implementation_node, - ($4 as initfinal_part).initialization_sect, ($4 as initfinal_part).finalization_sect, /*$1 as attribute_list*/ null, @$); + ($4 as initfinal_part).initialization_sect, ($4 as initfinal_part).finalization_sect, /*$1 as attribute_list*/ null, @$); + ($$ as compilation_unit).Language = PascalABCCompiler.StringConstants.pascalLanguageName; } | //attribute_declarations @@ -431,6 +432,7 @@ unit_file { $$ = new unit_module($1 as unit_name, $2 as interface_node, null, ($3 as initfinal_part).initialization_sect, ($3 as initfinal_part).finalization_sect, /*$1 as attribute_list*/ null, @$); + ($$ as compilation_unit).Language = PascalABCCompiler.StringConstants.pascalLanguageName; } ; diff --git a/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascalYacc.cs index de97287e7..43dd19986 100644 --- a/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Languages/Pascal/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: DESKTOP-V3E9T2U -// DateTime: 19.05.2024 23:53:53 +// DateTime: 25.05.2024 22:13:45 // UserName: alex // Input file @@ -3135,13 +3135,15 @@ public partial class GPPGParser: ShiftReduceParser unit_header, abc_interface_part, initialization_part, tkPoint { CurrentSemanticValue.stn = new unit_module(ValueStack[ValueStack.Depth-4].stn as unit_name, ValueStack[ValueStack.Depth-3].stn as interface_node, null, (ValueStack[ValueStack.Depth-2].stn as initfinal_part).initialization_sect, (ValueStack[ValueStack.Depth-2].stn as initfinal_part).finalization_sect, /*$1 as attribute_list*/ null, CurrentLocationSpan); + (CurrentSemanticValue.stn as compilation_unit).Language = PascalABCCompiler.StringConstants.pascalLanguageName; } break; case 49: // unit_header -> unit_key_word, unit_name, tkSemiColon, diff --git a/Languages/Pascal/PascalABCParserNewSaushkin/SemanticRulesForYacc.cs b/Languages/Pascal/PascalABCParserNewSaushkin/SemanticRulesForYacc.cs index 77e0ba666..dd16209e0 100644 --- a/Languages/Pascal/PascalABCParserNewSaushkin/SemanticRulesForYacc.cs +++ b/Languages/Pascal/PascalABCParserNewSaushkin/SemanticRulesForYacc.cs @@ -45,7 +45,7 @@ namespace Languages.Pascal.Frontend.Core public program_module NewProgramModule(program_name progName, Object optHeadCompDirs, uses_list mainUsesClose, syntax_tree_node progBlock, Object optPoint, LexLocation loc) { var progModule = new program_module(progName, mainUsesClose, progBlock as block, null, loc); - progModule.Language = LanguageId.PascalABCNET; + progModule.Language = PascalABCCompiler.StringConstants.pascalLanguageName; if (optPoint == null && progBlock != null) { var fp = progBlock.source_context.end_position; diff --git a/Languages/VisualBasic/VBNETParser/ASTConverter.cs b/Languages/VisualBasic/VBNETParser/ASTConverter.cs index 8cd869684..c026a6221 100644 --- a/Languages/VisualBasic/VBNETParser/ASTConverter.cs +++ b/Languages/VisualBasic/VBNETParser/ASTConverter.cs @@ -24,7 +24,7 @@ namespace PascalABCCompiler.VBNETParser if (td.Type == ICSharpCode.NRefactory.Ast.ClassType.Module) { mod = new unit_module(); - mod.Language = LanguageId.VBNET; + //mod.Language = "..."; // нужно заполнять !!! mod.file_name = FileName; mod.unit_name = new unit_name(); mod.unit_name.idunit_name = new ident(td.Name); diff --git a/SyntaxTree/SyntaxTree.csproj b/SyntaxTree/SyntaxTree.csproj index 91058aa20..2c2c071a8 100644 --- a/SyntaxTree/SyntaxTree.csproj +++ b/SyntaxTree/SyntaxTree.csproj @@ -148,6 +148,12 @@ true + + + {e8aefbf9-0113-4fa4-be45-6cda555498b7} + StringConstants + + diff --git a/SyntaxTree/tree/SyntaxTreeStreamReader.cs b/SyntaxTree/tree/SyntaxTreeStreamReader.cs index 8dfe58837..07751aa29 100644 --- a/SyntaxTree/tree/SyntaxTreeStreamReader.cs +++ b/SyntaxTree/tree/SyntaxTreeStreamReader.cs @@ -1474,7 +1474,14 @@ namespace PascalABCCompiler.SyntaxTree _compilation_unit.compiler_directives.Add(_read_node() as compiler_directive); } } - _compilation_unit.Language = (LanguageId)br.ReadByte(); + if (br.ReadByte() == 0) + { + _compilation_unit.Language = null; + } + else + { + _compilation_unit.Language = br.ReadString(); + } } diff --git a/SyntaxTree/tree/SyntaxTreeStreamWriter.cs b/SyntaxTree/tree/SyntaxTreeStreamWriter.cs index d3ed5ddc8..13e32c71f 100644 --- a/SyntaxTree/tree/SyntaxTreeStreamWriter.cs +++ b/SyntaxTree/tree/SyntaxTreeStreamWriter.cs @@ -1582,7 +1582,15 @@ namespace PascalABCCompiler.SyntaxTree } } } - bw.Write((byte)_compilation_unit.Language); + if (_compilation_unit.Language == null) + { + bw.Write((byte)0); + } + else + { + bw.Write((byte)1); + bw.Write(_compilation_unit.Language); + } } diff --git a/SyntaxTree/tree/Tree.cs b/SyntaxTree/tree/Tree.cs index ac3f0ee58..e1acdc382 100644 --- a/SyntaxTree/tree/Tree.cs +++ b/SyntaxTree/tree/Tree.cs @@ -1,6 +1,6 @@ -// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + using System; +using System.Collections; using System.Collections.Generic; namespace PascalABCCompiler.SyntaxTree @@ -12157,7 +12157,7 @@ namespace PascalABCCompiler.SyntaxTree /// ///Конструктор с параметрами. /// - public compilation_unit(string _file_name,List _compiler_directives,LanguageId _Language) + public compilation_unit(string _file_name,List _compiler_directives,string _Language) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; @@ -12168,7 +12168,7 @@ namespace PascalABCCompiler.SyntaxTree /// ///Конструктор с параметрами. /// - public compilation_unit(string _file_name,List _compiler_directives,LanguageId _Language,SourceContext sc) + public compilation_unit(string _file_name,List _compiler_directives,string _Language,SourceContext sc) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; @@ -12184,7 +12184,7 @@ namespace PascalABCCompiler.SyntaxTree protected string _file_name; protected List _compiler_directives=new List(); - protected LanguageId _Language; + protected string _Language; /// /// @@ -12219,7 +12219,7 @@ namespace PascalABCCompiler.SyntaxTree /// /// /// - public LanguageId Language + public string Language { get { @@ -12547,7 +12547,7 @@ namespace PascalABCCompiler.SyntaxTree /// ///Конструктор с параметрами. /// - public unit_module(string _file_name,List _compiler_directives,LanguageId _Language,unit_name _unit_name,interface_node _interface_part,implementation_node _implementation_part,statement_list _initialization_part,statement_list _finalization_part,attribute_list _attributes) + public unit_module(string _file_name,List _compiler_directives,string _Language,unit_name _unit_name,interface_node _interface_part,implementation_node _implementation_part,statement_list _initialization_part,statement_list _finalization_part,attribute_list _attributes) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; @@ -12564,7 +12564,7 @@ namespace PascalABCCompiler.SyntaxTree /// ///Конструктор с параметрами. /// - public unit_module(string _file_name,List _compiler_directives,LanguageId _Language,unit_name _unit_name,interface_node _interface_part,implementation_node _implementation_part,statement_list _initialization_part,statement_list _finalization_part,attribute_list _attributes,SourceContext sc) + public unit_module(string _file_name,List _compiler_directives,string _Language,unit_name _unit_name,interface_node _interface_part,implementation_node _implementation_part,statement_list _initialization_part,statement_list _finalization_part,attribute_list _attributes,SourceContext sc) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; @@ -12935,7 +12935,7 @@ namespace PascalABCCompiler.SyntaxTree /// ///Конструктор с параметрами. /// - public program_module(string _file_name,List _compiler_directives,LanguageId _Language,program_name _program_name,uses_list _used_units,block _program_block,using_list _using_namespaces) + public program_module(string _file_name,List _compiler_directives,string _Language,program_name _program_name,uses_list _used_units,block _program_block,using_list _using_namespaces) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; @@ -12950,7 +12950,7 @@ namespace PascalABCCompiler.SyntaxTree /// ///Конструктор с параметрами. /// - public program_module(string _file_name,List _compiler_directives,LanguageId _Language,program_name _program_name,uses_list _used_units,block _program_block,using_list _using_namespaces,SourceContext sc) + public program_module(string _file_name,List _compiler_directives,string _Language,program_name _program_name,uses_list _used_units,block _program_block,using_list _using_namespaces,SourceContext sc) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; @@ -34484,7 +34484,7 @@ namespace PascalABCCompiler.SyntaxTree /// ///Конструктор с параметрами. /// - public c_module(string _file_name,List _compiler_directives,LanguageId _Language,declarations _defs,uses_list _used_units) + public c_module(string _file_name,List _compiler_directives,string _Language,declarations _defs,uses_list _used_units) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; @@ -34497,7 +34497,7 @@ namespace PascalABCCompiler.SyntaxTree /// ///Конструктор с параметрами. /// - public c_module(string _file_name,List _compiler_directives,LanguageId _Language,declarations _defs,uses_list _used_units,SourceContext sc) + public c_module(string _file_name,List _compiler_directives,string _Language,declarations _defs,uses_list _used_units,SourceContext sc) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; diff --git a/SyntaxTree/tree/Tree.cs.txt b/SyntaxTree/tree/Tree.cs.txt index 96f47e798..004c3a155 100644 --- a/SyntaxTree/tree/Tree.cs.txt +++ b/SyntaxTree/tree/Tree.cs.txt @@ -202,7 +202,7 @@ program_body->syntax_tree_node compilation_unit->syntax_tree_node string file_name List compiler_directives - LanguageId Language + string Language unit_module->compilation_unit unit_name unit_name diff --git a/SyntaxTree/tree/TreeHelper.cs b/SyntaxTree/tree/TreeHelper.cs index 94230093b..451a0e05a 100644 --- a/SyntaxTree/tree/TreeHelper.cs +++ b/SyntaxTree/tree/TreeHelper.cs @@ -1,9 +1,10 @@ using System; -using System.Text; using System.Linq; using System.Collections.Generic; using System.Diagnostics; + +// TODO: рефакторинг для многоязычности EVA namespace PascalABCCompiler.SyntaxTree { /// @@ -382,7 +383,7 @@ namespace PascalABCCompiler.SyntaxTree { } public override string ToString() { - return string.Format("{0} {1} {2}", to, OperatorServices.ToString(operator_type, LanguageId.PascalABCNET), from); + return string.Format("{0} {1} {2}", to, OperatorServices.ToString(operator_type, StringConstants.pascalLanguageName), from); } public bool first_assignment_defines_type = false; } @@ -418,7 +419,7 @@ namespace PascalABCCompiler.SyntaxTree public override string ToString() { - return string.Format("{0} {2} {1}", left, right, OperatorServices.ToString(operation_type, LanguageId.PascalABCNET)); + return string.Format("{0} {2} {1}", left, right, OperatorServices.ToString(operation_type, StringConstants.pascalLanguageName)); } } @@ -430,7 +431,7 @@ namespace PascalABCCompiler.SyntaxTree } public override string ToString() { - return string.Format("{0} {1}", OperatorServices.ToString(operation_type, LanguageId.PascalABCNET), this.subnode); + return string.Format("{0} {1}", OperatorServices.ToString(operation_type, StringConstants.pascalLanguageName), this.subnode); } } @@ -969,7 +970,7 @@ namespace PascalABCCompiler.SyntaxTree public partial class unit_module { - public unit_module(LanguageId _Language, unit_name _unit_name, interface_node _interface_part, implementation_node _implementation_part, statement_list _initialization_part, statement_list _finalization_part, SourceContext sc) + public unit_module(string _Language, unit_name _unit_name, interface_node _interface_part, implementation_node _implementation_part, statement_list _initialization_part, statement_list _finalization_part, SourceContext sc) { this._Language = _Language; this._unit_name = _unit_name; @@ -981,7 +982,7 @@ namespace PascalABCCompiler.SyntaxTree } } - public partial class program_module + /*public partial class program_module { public static program_module create(ident id, uses_list _used_units, block _program_block, using_list _using_namespaces, SourceContext sc = null) { @@ -1001,7 +1002,7 @@ namespace PascalABCCompiler.SyntaxTree r.Language = LanguageId.CommonLanguage; return r; } - } + }*/ public partial class method_name { diff --git a/SyntaxTree/tree/TreeSubsidiary.cs b/SyntaxTree/tree/TreeSubsidiary.cs index 7565b1934..d85e4967f 100644 --- a/SyntaxTree/tree/TreeSubsidiary.cs +++ b/SyntaxTree/tree/TreeSubsidiary.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; namespace PascalABCCompiler.SyntaxTree { - public enum LanguageId { CommonLanguage=32, PascalABCNET=2, C=4, VBNET=8, Oberon00 = 16} public enum oberon_export_marker {export,export_readonly}; @@ -93,9 +92,11 @@ namespace PascalABCCompiler.SyntaxTree } return false; } - public static string ToString(Operators Operator, LanguageId Language) + + // TODO: рефакторинг для многоязычности EVA + public static string ToString(Operators Operator, string Language) { - if (Language == LanguageId.PascalABCNET) + if (Language == StringConstants.pascalLanguageName) { switch (Operator) { @@ -128,48 +129,6 @@ namespace PascalABCCompiler.SyntaxTree case Operators.Power: return "**"; } } - else - if (Language == LanguageId.C) - { - switch (Operator) - { - case Operators.Plus: return "+"; - case Operators.Minus: return "-"; - case Operators.Multiplication: return "*"; - case Operators.Division: return "/"; - case Operators.ModulusRemainder: return "%"; - case Operators.AssignmentAddition: return "+="; - case Operators.AssignmentSubtraction: return "-="; - case Operators.AssignmentMultiplication: return "*="; - case Operators.AssignmentDivision: return "/="; - case Operators.AssignmentModulus: return "%="; - case Operators.PrefixIncrement: return "++"; - case Operators.PostfixIncrement: return "++"; - case Operators.PrefixDecrement: return "--"; - case Operators.PostfixDecrement: return "--"; - case Operators.LogicalAND: return "%%"; - case Operators.LogicalOR: return "||"; - case Operators.Less: return "<"; - case Operators.Greater: return ">"; - case Operators.LessEqual: return "<="; - case Operators.GreaterEqual: return ">="; - case Operators.Equal: return "=="; - case Operators.NotEqual: return "!="; - case Operators.LogicalNOT: return "!"; - case Operators.BitwiseLeftShift: return "<<"; - case Operators.BitwiseRightShift: return ">>"; - case Operators.BitwiseAND: return "&"; - case Operators.BitwiseOR: return "|"; - case Operators.BitwiseXOR: return "^"; - case Operators.BitwiseNOT: return "~"; - case Operators.AssignmentBitwiseLeftShift: return "<<="; - case Operators.AssignmentBitwiseRightShift: return ">>="; - case Operators.AssignmentBitwiseAND: return "&="; - case Operators.AssignmentBitwiseOR: return "|="; - case Operators.AssignmentBitwiseXOR: return "^="; - case Operators.Assignment: return "="; - } - } return null; } } diff --git a/SyntaxTree/tree/tree.xml b/SyntaxTree/tree/tree.xml index d58c8bab5..07e095fcb 100644 --- a/SyntaxTree/tree/tree.xml +++ b/SyntaxTree/tree/tree.xml @@ -761,7 +761,7 @@ - + diff --git a/Utils/NodesGeneratorNew/ClassDiagram1.cd b/Utils/NodesGeneratorNew/ClassDiagram1.cd deleted file mode 100644 index 7b894197b..000000000 --- a/Utils/NodesGeneratorNew/ClassDiagram1.cd +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file