Skip to content

Commit

Permalink
added separate file for modifications, set classes as partial
Browse files Browse the repository at this point in the history
  • Loading branch information
georghinkel committed Nov 7, 2024
1 parent e17a489 commit 161a0b1
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 34 deletions.
16 changes: 16 additions & 0 deletions AnyText/AnyText.Core/Rules/SequenceRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ public override bool CanSynthesize(object semanticElement)
return Array.TrueForAll(Rules, r => r.CanSynthesize(semanticElement));
}

protected virtual bool IsOpeningParanthesis(string literal)
{
return literal == "(" || literal == "[" || literal == "{";
}

protected virtual bool IsMatchingClosingParanthesis(string literal, string openingParanthesis)
{
switch (openingParanthesis)
{
case "(": return literal == ")";
case "[": return literal == "]";
case "{": return literal == "}";
}
return false;
}

/// <inheritdoc />
public override RuleApplication Synthesize(object semanticElement, ParsePosition position, ParseContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ public class GrammarToClass : TransformationRule<IGrammar, CodeTypeDeclaration>
public override void Transform(IGrammar input, CodeTypeDeclaration output, ITransformationContext context)
{
output.Name = input.Name.ToPascalCase() + "Grammar";
output.IsPartial = true;
output.BaseTypes.Add(typeof(ReflectiveGrammar).ToTypeReference());

var languageId = new CodeMemberProperty
Expand Down Expand Up @@ -646,6 +647,7 @@ public override void Transform(IFeatureExpression input, CodeTypeDeclaration out
}
AddFormattingInstructions(initialize, input.FormattingInstructions.Concat(input.Assigned.FormattingInstructions));
output.Members.Add(initialize);
output.IsPartial = true;

var feature = new CodeMemberProperty
{
Expand Down
68 changes: 34 additions & 34 deletions AnyText/AnyText/Grammars/AnyTextGrammar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace NMF.AnyText.Grammars
{


public class AnyTextGrammar : ReflectiveGrammar
public partial class AnyTextGrammar : ReflectiveGrammar
{

public override string LanguageId
Expand Down Expand Up @@ -513,7 +513,7 @@ public override void Initialize(GrammarContext context)
}
}

public class GrammarRulesRule : AddAssignRule<IGrammar, IRule>
public partial class GrammarRulesRule : AddAssignRule<IGrammar, IRule>
{

protected override String Feature
Expand All @@ -537,7 +537,7 @@ public override ICollection<IRule> GetCollection(IGrammar semanticElement, Parse
}
}

public class GrammarImportsRule : AddAssignRule<IGrammar, IMetamodelImport>
public partial class GrammarImportsRule : AddAssignRule<IGrammar, IMetamodelImport>
{

protected override String Feature
Expand All @@ -559,7 +559,7 @@ public override ICollection<IMetamodelImport> GetCollection(IGrammar semanticEle
}
}

public class GrammarStartRuleRule : AssignModelReferenceRule<IGrammar, IClassRule>
public partial class GrammarStartRuleRule : AssignModelReferenceRule<IGrammar, IClassRule>
{

protected override String Feature
Expand Down Expand Up @@ -588,7 +588,7 @@ protected override void SetValue(IGrammar semanticElement, IClassRule propertyVa
}
}

public class GrammarLanguageIdRule : AssignRule<IGrammar, string>
public partial class GrammarLanguageIdRule : AssignRule<IGrammar, string>
{

protected override String Feature
Expand All @@ -615,7 +615,7 @@ protected override void SetValue(IGrammar semanticElement, string propertyValue,
}
}

public class GrammarNameRule : AssignRule<IGrammar, string>
public partial class GrammarNameRule : AssignRule<IGrammar, string>
{

protected override String Feature
Expand All @@ -642,7 +642,7 @@ protected override void SetValue(IGrammar semanticElement, string propertyValue,
}
}

public class MetamodelImportFileRule : AssignRule<IMetamodelImport, string>
public partial class MetamodelImportFileRule : AssignRule<IMetamodelImport, string>
{

protected override String Feature
Expand Down Expand Up @@ -671,7 +671,7 @@ protected override void SetValue(IMetamodelImport semanticElement, string proper
}
}

public class MetamodelImportPrefixRule : AssignRule<IMetamodelImport, string>
public partial class MetamodelImportPrefixRule : AssignRule<IMetamodelImport, string>
{

protected override String Feature
Expand All @@ -698,7 +698,7 @@ protected override void SetValue(IMetamodelImport semanticElement, string proper
}
}

public class InheritanceRuleSubtypesRule : AddAssignModelReferenceRule<IInheritanceRule, IClassRule>
public partial class InheritanceRuleSubtypesRule : AddAssignModelReferenceRule<IInheritanceRule, IClassRule>
{

protected override String Feature
Expand All @@ -720,7 +720,7 @@ public override ICollection<IClassRule> GetCollection(IInheritanceRule semanticE
}
}

public class RuleNameRule : AssignRule<IRule, string>
public partial class RuleNameRule : AssignRule<IRule, string>
{

protected override String Feature
Expand All @@ -747,7 +747,7 @@ protected override void SetValue(IRule semanticElement, string propertyValue, Pa
}
}

public class ModelRuleExpressionRule : AssignRule<IModelRule, IParserExpression>
public partial class ModelRuleExpressionRule : AssignRule<IModelRule, IParserExpression>
{

protected override String Feature
Expand Down Expand Up @@ -776,7 +776,7 @@ protected override void SetValue(IModelRule semanticElement, IParserExpression p
}
}

public class DataRuleEscapeRulesRule : AddAssignRule<IDataRule, IEscapeRule>
public partial class DataRuleEscapeRulesRule : AddAssignRule<IDataRule, IEscapeRule>
{

protected override String Feature
Expand All @@ -798,7 +798,7 @@ public override ICollection<IEscapeRule> GetCollection(IDataRule semanticElement
}
}

public class DataRuleSurroundCharacterRule : AssignRule<IDataRule, string>
public partial class DataRuleSurroundCharacterRule : AssignRule<IDataRule, string>
{

protected override String Feature
Expand All @@ -825,7 +825,7 @@ protected override void SetValue(IDataRule semanticElement, string propertyValue
}
}

public class DataRuleRegexRule : AssignRule<IDataRule, string>
public partial class DataRuleRegexRule : AssignRule<IDataRule, string>
{

protected override String Feature
Expand All @@ -852,7 +852,7 @@ protected override void SetValue(IDataRule semanticElement, string propertyValue
}
}

public class EscapeRuleEscapeRule : AssignRule<IEscapeRule, string>
public partial class EscapeRuleEscapeRule : AssignRule<IEscapeRule, string>
{

protected override String Feature
Expand All @@ -879,7 +879,7 @@ protected override void SetValue(IEscapeRule semanticElement, string propertyVal
}
}

public class EscapeRuleCharacterRule : AssignRule<IEscapeRule, string>
public partial class EscapeRuleCharacterRule : AssignRule<IEscapeRule, string>
{

protected override String Feature
Expand All @@ -906,7 +906,7 @@ protected override void SetValue(IEscapeRule semanticElement, string propertyVal
}
}

public class FragmentRuleExpressionRule : AssignRule<IFragmentRule, IParserExpression>
public partial class FragmentRuleExpressionRule : AssignRule<IFragmentRule, IParserExpression>
{

protected override String Feature
Expand Down Expand Up @@ -935,7 +935,7 @@ protected override void SetValue(IFragmentRule semanticElement, IParserExpressio
}
}

public class RuleTypeNameRule : AssignRule<IRule, string>
public partial class RuleTypeNameRule : AssignRule<IRule, string>
{

protected override String Feature
Expand All @@ -962,7 +962,7 @@ protected override void SetValue(IRule semanticElement, string propertyValue, Pa
}
}

public class RulePrefixRule : AssignRule<IRule, string>
public partial class RulePrefixRule : AssignRule<IRule, string>
{

protected override String Feature
Expand Down Expand Up @@ -991,7 +991,7 @@ protected override void SetValue(IRule semanticElement, string propertyValue, Pa
}
}

public class ParanthesisRuleClosingParanthesisRule : AssignRule<IParanthesisRule, IKeywordExpression>
public partial class ParanthesisRuleClosingParanthesisRule : AssignRule<IParanthesisRule, IKeywordExpression>
{

protected override String Feature
Expand Down Expand Up @@ -1020,7 +1020,7 @@ protected override void SetValue(IParanthesisRule semanticElement, IKeywordExpre
}
}

public class ParanthesisRuleInnerRuleRule : AssignModelReferenceRule<IParanthesisRule, IClassRule>
public partial class ParanthesisRuleInnerRuleRule : AssignModelReferenceRule<IParanthesisRule, IClassRule>
{

protected override String Feature
Expand All @@ -1047,7 +1047,7 @@ protected override void SetValue(IParanthesisRule semanticElement, IClassRule pr
}
}

public class ParanthesisRuleOpeningParanthesisRule : AssignRule<IParanthesisRule, IKeywordExpression>
public partial class ParanthesisRuleOpeningParanthesisRule : AssignRule<IParanthesisRule, IKeywordExpression>
{

protected override String Feature
Expand All @@ -1074,7 +1074,7 @@ protected override void SetValue(IParanthesisRule semanticElement, IKeywordExpre
}
}

public class EnumRuleLiteralsRule : AddAssignRule<IEnumRule, ILiteralRule>
public partial class EnumRuleLiteralsRule : AddAssignRule<IEnumRule, ILiteralRule>
{

protected override String Feature
Expand All @@ -1096,7 +1096,7 @@ public override ICollection<ILiteralRule> GetCollection(IEnumRule semanticElemen
}
}

public class LiteralRuleKeywordRule : AssignRule<ILiteralRule, string>
public partial class LiteralRuleKeywordRule : AssignRule<ILiteralRule, string>
{

protected override String Feature
Expand Down Expand Up @@ -1125,7 +1125,7 @@ protected override void SetValue(ILiteralRule semanticElement, string propertyVa
}
}

public class LiteralRuleLiteralRule : AssignRule<ILiteralRule, string>
public partial class LiteralRuleLiteralRule : AssignRule<ILiteralRule, string>
{

protected override String Feature
Expand All @@ -1152,7 +1152,7 @@ protected override void SetValue(ILiteralRule semanticElement, string propertyVa
}
}

public class SequenceExpressionInnerExpressionsRule : AddAssignRule<ISequenceExpression, IParserExpression>
public partial class SequenceExpressionInnerExpressionsRule : AddAssignRule<ISequenceExpression, IParserExpression>
{

protected override String Feature
Expand All @@ -1174,7 +1174,7 @@ public override ICollection<IParserExpression> GetCollection(ISequenceExpression
}
}

public class UnaryParserExpressionInnerRule : AssignRule<IUnaryParserExpression, IParserExpression>
public partial class UnaryParserExpressionInnerRule : AssignRule<IUnaryParserExpression, IParserExpression>
{

protected override String Feature
Expand Down Expand Up @@ -1203,7 +1203,7 @@ protected override void SetValue(IUnaryParserExpression semanticElement, IParser
}
}

public class KeywordExpressionKeywordRule : AssignRule<IKeywordExpression, string>
public partial class KeywordExpressionKeywordRule : AssignRule<IKeywordExpression, string>
{

protected override String Feature
Expand All @@ -1230,7 +1230,7 @@ protected override void SetValue(IKeywordExpression semanticElement, string prop
}
}

public class ChoiceExpressionAlternativesRule : AddAssignRule<IChoiceExpression, IParserExpression>
public partial class ChoiceExpressionAlternativesRule : AddAssignRule<IChoiceExpression, IParserExpression>
{

protected override String Feature
Expand All @@ -1252,7 +1252,7 @@ public override ICollection<IParserExpression> GetCollection(IChoiceExpression s
}
}

public class FeatureExpressionAssignedRule : AssignRule<IFeatureExpression, IParserExpression>
public partial class FeatureExpressionAssignedRule : AssignRule<IFeatureExpression, IParserExpression>
{

protected override String Feature
Expand All @@ -1279,7 +1279,7 @@ protected override void SetValue(IFeatureExpression semanticElement, IParserExpr
}
}

public class FeatureExpressionFeatureRule : AssignRule<IFeatureExpression, string>
public partial class FeatureExpressionFeatureRule : AssignRule<IFeatureExpression, string>
{

protected override String Feature
Expand Down Expand Up @@ -1308,7 +1308,7 @@ protected override void SetValue(IFeatureExpression semanticElement, string prop
}
}

public class RuleExpressionRuleRule : AssignModelReferenceRule<IRuleExpression, IRule>
public partial class RuleExpressionRuleRule : AssignModelReferenceRule<IRuleExpression, IRule>
{

protected override String Feature
Expand All @@ -1335,7 +1335,7 @@ protected override void SetValue(IRuleExpression semanticElement, IRule property
}
}

public class ReferenceExpressionReferencedRuleRule : AssignModelReferenceRule<IReferenceExpression, IClassRule>
public partial class ReferenceExpressionReferencedRuleRule : AssignModelReferenceRule<IReferenceExpression, IClassRule>
{

protected override String Feature
Expand Down Expand Up @@ -1364,7 +1364,7 @@ protected override void SetValue(IReferenceExpression semanticElement, IClassRul
}
}

public class ParserExpressionFormattingInstructionsRule : AddAssignRule<IParserExpression, NMF.AnyText.Metamodel.FormattingInstruction>
public partial class ParserExpressionFormattingInstructionsRule : AddAssignRule<IParserExpression, NMF.AnyText.Metamodel.FormattingInstruction>
{

protected override String Feature
Expand Down
21 changes: 21 additions & 0 deletions AnyText/AnyText/Grammars/AnyTextGrammar.manual.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NMF.AnyText.Grammars
{
public partial class AnyTextGrammar
{
public partial class AddAssignExpressionRule
{
public override string TokenType => "keyword";
}

public partial class ModelRuleRule
{

}
}
}

0 comments on commit 161a0b1

Please sign in to comment.