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

struct/module/class concept #35

Closed
4 tasks done
ppaulweber opened this issue Jul 28, 2017 · 1 comment · Fixed by #113
Closed
4 tasks done

struct/module/class concept #35

ppaulweber opened this issue Jul 28, 2017 · 1 comment · Fixed by #113

Comments

@ppaulweber
Copy link
Contributor

ppaulweber commented Jul 28, 2017

  • add new grammar syntax for the struct/module/class concept
  • provide unit test cases to the TC repository
  • implement IR representation
  • add proper run-time implementation and AST execution etc.

As already discussed 2 years ago, please add the struct/module/class concept to the CASM language. Inspired by the RUST language and the "traits" concept, we define the following syntax and semantics of our struct~~/module/class~~ concept and call the trait a feature:

structure ::= 'structure' identifier '=' '{' functionDefinitions '}'

feature ::= 'feature' identifier '=' '{' ( declaration | definition )+ '}'

declaration ::= kind identifier ':' typeRelation

implements ::= 'implements' [ identifier 'for' ] identifier '=' '{' definitions '}'

Furthermore, we also need a new keyword this to reference in implementations the correct overlapping structure attributes etc.

example struct/module/class definition Counter.casm:

CASM init foo 

// definition of the structure, traits and the implementation of it
structure Counter =
{
    function value : -> Integer
}

feature Incrementor =
{
    rule increment : -> Void
    derived next : -> Integer
}

implements Counter =
{
    derived value -> String = asString( this.value )
}

implements Incrementor for Counter =
{
    rule increment =
    {
        this.value := this.next()
    }
    derived next -> Integer = this.value + 1
}

function c : -> Counter

rule foo = 
{
    call c.increment()
    println( c.value() )
}
@ppaulweber
Copy link
Contributor Author

ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* removed invalid COMMA terminal
  - related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* fixed incorrect attributed and non-attributed function definition list
  for structure definitions
* updated comments
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* fixed incorrect signatures
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* added missing attributes visiting calls for the new structure,
  feature, implementation and declaration definitions
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* fixed incorrect indention implementation for structure, feature and
  implementation definitions
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* added structure definition implementation
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* added feature definition
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* added implementation definition
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* added declaration definition
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* changed grammar to set the 'init' parsing to the top-level of the
  definitions, due to the fact of a reuse of the 'FunctionDefinition' in
  'StructureDefinition', which leads to a incorrect 'init' sub-rule in
  structures, which is incorrect
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* fixed syntax to support attributes as well
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* fixed ctor to directly initialize the kind type
* renamed in grammar to 'Declaration' for readability reasons
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jul 31, 2017
* fixed syntax rules
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Aug 1, 2017
* fixed syntax and definition for implementation
* related to ref sealangdotorg/sea#35
@ppaulweber ppaulweber removed the casm label Oct 24, 2017
@ppaulweber ppaulweber mentioned this issue Nov 6, 2017
1 task
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Nov 9, 2017
* added besides the 'fromExpression' and 'asType' information a direct
  call expression node as member, which is used to resolve the 'as'
  operator and gets called during the execution etc.
* this 'typeCasting' direct call member is chosen, because of the
  possibility to perform besides built-ins with other forms type casting
  operations (e.g. the features, see sealangdotorg/sea#35
* related to sealangdotorg/sea#48
@ppaulweber ppaulweber removed this from the release_auxentios milestone Nov 21, 2017
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Mar 3, 2020
* added structure definition implementation
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Mar 3, 2020
* added feature definition
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Mar 3, 2020
* added implementation definition
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Mar 3, 2020
* added declaration definition
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Mar 3, 2020
* fixed syntax to support attributes as well
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Mar 3, 2020
* fixed ctor to directly initialize the kind type
* renamed in grammar to 'Declaration' for readability reasons
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Mar 3, 2020
* fixed syntax rules
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Mar 3, 2020
* fixed syntax and definition for implementation
* related to ref sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* removed invalid COMMA terminal
  - related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* fixed incorrect attributed and non-attributed function definition list
  for structure definitions
* updated comments
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* fixed incorrect signatures
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* added missing attributes visiting calls for the new structure,
  feature, implementation and declaration definitions
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* added structure definition implementation
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* added feature definition
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* added implementation definition
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* added declaration definition
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* fixed syntax to support attributes as well
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* fixed ctor to directly initialize the kind type
* renamed in grammar to 'Declaration' for readability reasons
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* fixed syntax rules
* related to sealangdotorg/sea#35
ppaulweber added a commit to casm-lang/libcasm-fe that referenced this issue Jun 11, 2021
* fixed syntax and definition for implementation
* related to ref sealangdotorg/sea#35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants