Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate syntax - poc 1 #789

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
695b71d
Implemented basic syntax and scoping
SimonCockx Mar 6, 2024
274673c
fixes
SimonCockx Mar 11, 2024
deab2c5
fixed highlighting
SimonCockx Apr 18, 2024
e51cd68
WIP
SimonCockx May 15, 2024
dc5eeec
Implemented syntax and scoping
SimonCockx May 21, 2024
9907d84
WIP
SimonCockx May 28, 2024
e334027
Merged
SimonCockx Jun 6, 2024
33fd848
WIP
SimonCockx Jun 7, 2024
18addbe
Fixed highlighting
SimonCockx Jun 7, 2024
3831c84
Implemented validation, formatting and highlighting
SimonCockx Jun 10, 2024
6448a71
Fixed
SimonCockx Jun 10, 2024
df999f9
Merged
SimonCockx Jun 10, 2024
2a2fab1
Merge branch 'main' into translate-syntax
SimonCockx Jun 14, 2024
dbc38a2
Added param to branch deploy
SimonCockx Jun 14, 2024
685f4be
Merge branch 'translate-syntax' of https://github.com/finos/rune-dsl …
SimonCockx Jun 14, 2024
8c543c5
Branch deploy fix
SimonCockx Jun 14, 2024
352ef40
add import as syntax with validation
davidalk Jul 2, 2024
4c35550
use correct xtext type for alias
davidalk Jul 2, 2024
e977086
add failing import alias test
davidalk Jul 3, 2024
9e866d3
save
davidalk Jul 4, 2024
e6cb402
Merge branch 'main' of https://github.com/finos/rune-dsl into transla…
SimonCockx Jul 4, 2024
473345c
WIP
SimonCockx Jul 4, 2024
96432ab
WIP
SimonCockx Jul 4, 2024
34b6cd2
implement alias aware normalizer
davidalk Jul 5, 2024
6fb8692
Merge remote-tracking branch 'origin/main' into translate-syntax-3
davidalk Jul 5, 2024
448a06d
Merge branch 'main' into translate-syntax-3
davidalk Jul 5, 2024
62de8b3
Merge branch 'main' into translate-syntax
SimonCockx Jul 5, 2024
49c8d17
fix deresolve bug for import as
davidalk Jul 5, 2024
53ba2a2
Merge branch 'translate-syntax' of github.com:finos/rune-dsl into tra…
davidalk Jul 5, 2024
7e64ef6
remove reduced dep pom
davidalk Jul 5, 2024
c8b47f1
update gitignore
davidalk Jul 5, 2024
5f8ffd9
Implemented code generation excluding meta features
SimonCockx Jul 5, 2024
473a181
Merge branch 'translate-syntax' of https://github.com/finos/rune-dsl …
SimonCockx Jul 5, 2024
21c4045
Merge branch 'translate-syntax' of https://github.com/regnosys/rune-d…
SimonCockx Jul 5, 2024
47e95c3
use standard import normalizer when alias not present
davidalk Jul 5, 2024
2b225b0
Corrections
SimonCockx Jul 5, 2024
0a02446
Merge branch 'translate-syntax' of https://github.com/regnosys/rune-d…
SimonCockx Jul 5, 2024
5aaa7f9
Merge remote-tracking branch 'origin/main' into translate-syntax
davidalk Jul 18, 2024
54c286b
Fix incorrectly updated test expectation
davidalk Jul 19, 2024
e12dfe8
fix issue with importing same namespace from two models
davidalk Jul 19, 2024
bbee346
fix alias validation error assert
davidalk Jul 19, 2024
12f4e99
disable translate with meta test to run build
davidalk Jul 19, 2024
14ac558
Limit class name sizes when they would cause file length over 255
davidalk Jul 22, 2024
49f8d9e
remove print
davidalk Jul 22, 2024
1fa7591
Update ROperation to handle meta feature
davidalk Jul 23, 2024
d4e9847
Build generation, still need import
davidalk Jul 23, 2024
bc1531c
got it working!
davidalk Jul 23, 2024
c0bad4a
Test that other meta types are not set
davidalk Jul 24, 2024
bd51037
Use generated import for MetaFields
davidalk Jul 24, 2024
ef3252f
Implemented meta operation Java generation
SimonCockx Jul 29, 2024
92e671f
Merge branch 'main' into translate-syntax
SimonCockx Jul 29, 2024
5945387
Fixed multi meta generation
SimonCockx Jul 29, 2024
0c61417
Fixed external keys/references
SimonCockx Jul 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions .github/workflows/branch-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Deploy a branch as a snapshot version.

on:
workflow_dispatch:
inputs:
run-tests:
type: boolean
description: Run tests
default: true

# Cancel previous jobs
concurrency:
Expand All @@ -12,15 +17,28 @@ jobs:
deploy-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Normalize branch name
id: normalize-branch-name
uses: ./.github/actions/normalize-branch-name
- name: Set version
run: mvn -B versions:set -DnewVersion=0.0.0.${{ steps.normalize-branch-name.outputs.normalized }}-SNAPSHOT
- uses: ./.github/actions/maven-build
with:
build-command: deploy # Deploy a snapshot build of main
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
- uses: actions/checkout@v4
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
architecture: x64
cache: maven
server-id: ossrh
server-username: CI_DEPLOY_USERNAME
server-password: CI_DEPLOY_PASSWORD
gpg-private-key: ${{ secrets.RUNE_GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Normalize branch name
id: normalize-branch-name
uses: ./.github/actions/normalize-branch-name
- name: Set version
run: mvn -B versions:set -DgenerateBackupPoms=false -DnewVersion=0.0.0.${{ steps.normalize-branch-name.outputs.normalized }}-SNAPSHOT
- uses: ./.github/actions/maven-build
with:
build-command: deploy
run-tests: ${{ inputs.run-tests }}
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
115 changes: 109 additions & 6 deletions rosetta-ide/rosetta.tmLanguage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ variables:
# - keywords that may also be used as an identifier (e.g., `version`),
# - keywords that may also be used as another keyword in a certain context (e.g., `synonym`),
# - keywords that are unambiguous, i.e., all other keywords indicating the start of a root element.
identifiersConflictingWithRootStart: '{{wordStart}}(version){{wordEnd}}'
identifiersConflictingWithRootStart: '{{wordStart}}(translate){{wordEnd}}'
identifiersConflictingWithNamespace: '{{wordStart}}(version){{wordEnd}}'
ambiguousRootStart: '{{wordStart}}(synonym|rule){{wordEnd}}'
unambiguousRootStart: '{{wordStart}}(namespace|import|isEvent|isProduct|body|corpus|segment|basicType|recordType|typeAlias|library|reporting|eligibility|metaType|report|annotation|enum|type|choice|func){{wordEnd}}'
rootStart: '{{identifiersConflictingWithRootStart}}|{{ambiguousRootStart}}|{{unambiguousRootStart}}'
strictRootEnd: (?={{rootStart}})
rootEnd: (?={{ambiguousRootStart}}|{{unambiguousRootStart}})
rootStart: '{{identifiersConflictingWithRootStart}}|{{identifiersConflictingWithNamespace}}|{{ambiguousRootStart}}|{{unambiguousRootStart}}'
namespaceEnd: (?={{identifiersConflictingWithNamespace}}|{{ambiguousRootStart}}|{{unambiguousRootStart}})
rootEnd: (?={{identifiersConflictingWithRootStart}}|{{ambiguousRootStart}}|{{unambiguousRootStart}})
unambiguousRootEnd: (?={{unambiguousRootStart}})

sectionStart: '{{wordStart}}((\Qpost-\E)?condition|set|add|inputs|output|alias){{wordEnd}}'
Expand All @@ -45,7 +46,7 @@ variables:
synonymAnnotationSectionEnd: (?={{synonymAnnotationSection}})|(?=\])|{{rootEnd}}
docReferenceAnnotationSection: '{{wordStart}}(rationale|rationale_author|structured_provision|provision|reportedField){{wordEnd}}'
docReferenceAnnotationSectionEnd: (?={{docReferenceAnnotationSection}}|\])|{{sectionEnd}}
expressionEnd: '(?=,|\)|\])|{{sectionEnd}}'
expressionEnd: '(?=,|\)|\]|\})|{{sectionEnd}}'
functionalOperationEnd: (?={{listOperation}}|{{wordStart}}(else|then){{wordEnd}})|{{expressionEnd}}

patterns:
Expand Down Expand Up @@ -78,7 +79,7 @@ repository:
begin: '{{wordStart}}namespace{{wordEnd}}'
beginCaptures:
0: { name: keyword.other.namespace.rosetta }
end: '{{strictRootEnd}}'
end: '{{namespaceEnd}}'
patterns:
- include: '#comment'
- include: '#documentation'
Expand Down Expand Up @@ -146,6 +147,7 @@ repository:
- include: '#rosettaTypeAlias'
- include: '#rosettaLibraryFunction'
- include: '#rosettaAnnotationSource'
- include: '#rosettaTranslateSource'
- include: '#rosettaRule'
- include: '#rosettaMetaType'
- include: '#rosettaReport'
Expand Down Expand Up @@ -453,6 +455,74 @@ repository:
- include: '#comment'
- include: '#annotation'

rosettaTranslateSource:
name: meta.translate-source.rosetta
begin: '{{wordStart}}translate{{wordEnd}}'
beginCaptures:
0: { name: keyword.other.translate.rosetta }
end: (\})|{{rootEnd}}
endCaptures:
1: { name: punctuation.section.braces.end.rosetta }
patterns:
- include: '#comment'
- begin: '(?<={{wordStart}}translate{{wordEnd}})'
end: (?=\{)|{{rootEnd}}
patterns:
- include: '#comment'
- name: keyword.other.source.rosetta
match: '{{wordStart}}source{{wordEnd}}'
- name: keyword.other.extends.rosetta
match: '{{wordStart}}extends{{wordEnd}}'
- name: entity.name.translate-source.rosetta
match: '{{identifier}}'
- name: meta.translate-source-body.rosetta
begin: (\{)
beginCaptures:
1: { name: punctuation.section.braces.begin.rosetta }
end: (?=\})|{{unambiguousRootEnd}}
patterns:
- include: '#comment'
- name: meta.translation.inputs.rosetta
begin: ({{wordStart}}from{{wordEnd}})
beginCaptures:
1: { name: keyword.other.from.rosetta }
end: (?=\:|\})|{{rootEnd}}
patterns:
- include: '#comment'
- begin: '(?={{identifier}})'
end: '(,)|(?=\:|\})|{{rootEnd}}'
endCaptures:
1: { name: punctuation.separator.comma.rosetta }
patterns:
- include: '#comment'
- begin: '({{identifier}})\s+(?={{identifier}})'
beginCaptures:
1: { name: variable.parameter.input.rosetta }
end: '(?=,)|(?=\:|\})|{{rootEnd}}'
patterns:
- include: '#comment'
- include: '#typeCall'
- include: '#typeCall'
- name: meta.translation.result-type.rosetta
begin: '(?={{identifier}})'
end: (?={{wordStart}}from{{wordEnd}})|(?=\:|\})|{{rootEnd}}
patterns:
- include: '#comment'
- name: keyword.other.from.rosetta
match: '{{wordStart}}from{{wordEnd}}'
- include: '#typeCall'
- include: '#colon'
- include: '#translateAnnotation'
- name: meta.translation-attribute-mapping.rosetta
begin: '(\+|-)\s*({{identifier}})'
beginCaptures:
1: { name: keyword.operator.annotation.rosetta }
2: { name: variable.other.member.rosetta }
end: (?={{identifier}}|\}|\+|-)|{{rootEnd}}
patterns:
- include: '#comment'
- include: '#translateAnnotation'

rosettaRule:
patterns:
- name: meta.rule.rosetta
Expand Down Expand Up @@ -722,6 +792,39 @@ repository:
- include: '#comment'
- name: entity.name.rule.rosetta
match: '{{identifier}}'

translateAnnotation:
name: meta.annotated.translate.rosetta
begin: (\[)
beginCaptures:
1: { name: punctuation.annotation.begin.rosetta }
end: (\])|{{unambiguousRootEnd}}
endCaptures:
1: { name: punctuation.annotation.end.rosetta }
patterns:
- include: '#comment'
- include: '#translateInstructionAnnotationBody'
- include: '#translateMetaInstructionAnnotationBody'

translateInstructionAnnotationBody:
begin: '{{wordStart}}from{{wordEnd}}'
beginCaptures:
0: { name: keyword.other.from.rosetta }
end: (?=\]|\})|{{rootEnd}}
patterns:
- include: '#comment'
- include: '#expression'

translateMetaInstructionAnnotationBody:
begin: '{{wordStart}}meta{{wordEnd}}'
beginCaptures:
0: { name: keyword.other.meta.rosetta }
end: (?=\]|\})|{{rootEnd}}
patterns:
- include: '#comment'
- include: '#translateInstructionAnnotationBody'
- name: variable.other.member.meta.rosetta
match: '{{identifier}}'

customAnnotationBody:
name: meta.annotated.rosetta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.regnosys.rosetta.rosetta.RosettaSymbol;
import com.regnosys.rosetta.rosetta.RosettaType;
import com.regnosys.rosetta.rosetta.RosettaTypeAlias;
import com.regnosys.rosetta.rosetta.translate.TranslationParameter;
import com.regnosys.rosetta.rosetta.TypeCall;
import com.regnosys.rosetta.rosetta.TypeParameter;
import com.regnosys.rosetta.rosetta.expression.ClosureParameter;
Expand Down Expand Up @@ -264,6 +265,8 @@ private SemanticToken markSymbol(EObject objectToMark, EStructuralFeature featur
return markAlias(objectToMark, featureToMark, (ShortcutDeclaration)symbol);
} else if (symbol instanceof TypeParameter) {
return createSemanticToken(objectToMark, featureToMark, PARAMETER);
} else if (symbol instanceof TranslationParameter) {
return createSemanticToken(objectToMark, featureToMark, PARAMETER);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class ContentAssistTest extends AbstractRosettaLanguageServerTest {
to-string -> to-string [[7, 27] .. [7, 27]]
to-time -> to-time [[7, 27] .. [7, 27]]
to-zoned-date-time -> to-zoned-date-time [[7, 27] .. [7, 27]]
translate -> translate [[7, 27] .. [7, 27]]
type -> type [[7, 27] .. [7, 27]]
typeAlias -> typeAlias [[7, 27] .. [7, 27]]
* -> * [[7, 27] .. [7, 27]]
Expand Down
13 changes: 5 additions & 8 deletions rosetta-lang/model/Rosetta.xcore
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class RosettaModel extends RosettaDefinable {

class Import {
String importedNamespace
String namespaceAlias

}


/**********************************************************************
* Common types
*/
Expand All @@ -45,16 +48,10 @@ interface RosettaTyped {
}
}

class RosettaFeature extends RosettaNamed {
/**
* @return The name or 'value' if it's <code>null</code>
*/
derived String getNameOrDefault get {
return name ?: 'value'
}
interface RosettaFeature extends RosettaNamed {
}

class RosettaTypedFeature extends RosettaFeature, RosettaTyped {}
interface RosettaTypedFeature extends RosettaFeature, RosettaTyped {}

/**
* A named symbol that may be used in an expression to reference an object
Expand Down
8 changes: 8 additions & 0 deletions rosetta-lang/model/RosettaExpression.xcore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import com.regnosys.rosetta.rosetta.RosettaFeature
import com.regnosys.rosetta.rosetta.RosettaCallableWithArgs
import com.regnosys.rosetta.rosetta.RosettaMapTestExpression
import com.regnosys.rosetta.rosetta.RosettaTyped
import com.regnosys.rosetta.rosetta.TypeCall
import com.regnosys.rosetta.rosetta.simple.Attribute
import com.regnosys.rosetta.rosetta.translate.TranslateSource
import org.eclipse.emf.common.util.BasicEList


Expand Down Expand Up @@ -170,6 +172,12 @@ class ConstructorKeyValuePair {
contains RosettaExpression value
}

class TranslateDispatchOperation extends RosettaExpression {
refers TranslateSource source
refers RosettaExpression[] inputs
refers TypeCall outputType
}

interface RosettaOperation extends RosettaExpression {
String operator
}
Expand Down
56 changes: 56 additions & 0 deletions rosetta-lang/model/RosettaTranslate.xcore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@Ecore(nsURI="http://www.rosetta-model.com/RosettaTranslate")
@GenModel(fileExtensions="rosetta", modelDirectory="/com.regnosys.rosetta/emf-gen/main/java", operationReflection="false",
copyrightText="Copyright (c) REGnosys 2017 (www.regnosys.com)", forceOverwrite="true", updateClasspath="false",
complianceLevel="8.0", bundleManifest="false", modelPluginID="")
package com.regnosys.rosetta.rosetta.translate

import com.regnosys.rosetta.rosetta.simple.Attribute
import com.regnosys.rosetta.rosetta.RosettaMetaType
import com.regnosys.rosetta.rosetta.RosettaNamed
import com.regnosys.rosetta.rosetta.RosettaRootElement
import com.regnosys.rosetta.rosetta.RosettaSymbol
import com.regnosys.rosetta.rosetta.RosettaTyped
import com.regnosys.rosetta.rosetta.TypeCall
import com.regnosys.rosetta.rosetta.expression.RosettaExpression
import com.regnosys.rosetta.rosetta.expression.TranslateDispatchOperation

class TranslateSource extends RosettaRootElement, RosettaNamed {
refers TranslateSource[] superSources
contains Translation[] translations opposite source
}

class Translation {
refers TranslateSource source opposite translations

contains TypeCall resultType
contains TranslationParameter[] parameters
contains TranslateInstruction[] typeInstructions
contains TranslateMetaInstruction[] typeMetaInstructions

contains TranslationRule[] rules opposite translation
}

class TranslationParameter extends RosettaSymbol, RosettaTyped {

}

class TranslationRule {
refers Translation translation opposite rules

refers Attribute attribute
contains TranslateInstruction[] instructions
contains TranslateMetaInstruction[] metaInstructions
}

abstract class BaseTranslateInstruction {
contains TranslateDispatchOperation _internalDispatchExpression

contains RosettaExpression[] expressions
}

class TranslateInstruction extends BaseTranslateInstruction {
}

class TranslateMetaInstruction extends BaseTranslateInstruction {
refers RosettaMetaType metaFeature
}
1 change: 1 addition & 0 deletions rosetta-lang/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<include>model/Rosetta.xcore</include>
<include>model/RosettaSimple.xcore</include>
<include>model/RosettaExpression.xcore</include>
<include>model/RosettaTranslate.xcore</include>
</includes>
</resource>
<resource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Workflow {
referencedResource = "platform:/resource/com.regnosys.rosetta/model/Rosetta.xcore"
referencedResource = "platform:/resource/com.regnosys.rosetta/model/RosettaSimple.xcore"
referencedResource = "platform:/resource/com.regnosys.rosetta/model/RosettaExpression.xcore"
referencedResource = "platform:/resource/com.regnosys.rosetta/model/RosettaTranslate.xcore"
name = "com.regnosys.rosetta.Rosetta"
fileExtensions = "rosetta"

Expand Down
Loading
Loading