Casting improvement, parseTypedDeclaration() #110

Closed
opened 2023-04-14 11:55:13 +01:00 by deavmi · 10 comments
Owner

What is this?

To add support for parseType() which could hold the code that parseTypedDeclaration() uses when it parses the <type> <identifier> ['=' <assigment>] ';' (the <type> part).

Technically this will help us with:

  1. parseCast() #87
  2. Support for arrays in #81 (we can hoist a lot of that into this - possibly) - we might have to see - but worth looking at
## What is this? To add support for `parseType()` which could hold the code that `parseTypedDeclaration()` uses when it parses the `<type> <identifier> ['=' <assigment>] ';'` (the `<type>` part). Technically this will help us with: 1. `parseCast()` #87 2. Support for arrays in #81 (we can hoist a lot of that into this - possibly) - we might have to see - but worth looking at
deavmi added the
parser
label 2023-04-14 11:56:33 +01:00
deavmi added this to the Parser project 2023-04-14 11:56:35 +01:00
deavmi added this to the Basics milestone 2023-04-14 11:56:38 +01:00
deavmi self-assigned this 2023-04-14 11:56:41 +01:00
Author
Owner

Solution potentiale

We could rather keep parseTypedDeclaration(...) as is and add another default argument bool wantsAssignment (or RATHER re-use that maybe to mean assignment in the cases of non function?)

## Solution potentiale We _could_ rather keep `parseTypedDeclaration(...)` as is and add another default argument `bool wantsAssignment` (or RATHER re-use that maybe to mean assignment in the cases of non function?)
deavmi added reference vardec_varass_dependency 2023-04-14 11:58:49 +01:00
Author
Owner

Solution potentiale

We could rather keep parseTypedDeclaration(...) as is and add another default argument bool wantsAssignment (or RATHER re-use that maybe to mean assignment in the cases of non function?)

We do this already look...

/* Check for `=` (var dec) */
else if (symbolType == SymbolType.ASSIGN)
{
	// Only continue if variable declarations are allowed
    if(allowVarDec)
    {
    	// Only continue if assignments are allowed
        if(wantsBody)
        {
        	/* Consume the `=` token */
            nextToken();
            
            ...
> ## Solution potentiale > > We _could_ rather keep `parseTypedDeclaration(...)` as is and add another default argument `bool wantsAssignment` (or RATHER re-use that maybe to mean assignment in the cases of non function?) We do this already look... ```d /* Check for `=` (var dec) */ else if (symbolType == SymbolType.ASSIGN) { // Only continue if variable declarations are allowed if(allowVarDec) { // Only continue if assignments are allowed if(wantsBody) { /* Consume the `=` token */ nextToken(); ... ```
Author
Owner

Okay, next thing though - it returns a TypedEntity and DOES expect an identifier. We may need to add a new flag to say dontExpectIdentifier.

Okay, next thing though - it returns a `TypedEntity` and DOES expect an identifier. We may need to add a new flag to say `dontExpectIdentifier`.
Author
Owner

Solution potentiale 2

Okay, next thing though - it returns a TypedEntity and DOES expect an identifier. We may need to add a new flag to say dontExpectIdentifier.

  1. Actually, just have a onlyType=true, then we stop there rather.
  2. It returns a TypedEntity, so it needs a name? Perhaps we generate a bogus one with an empty identifier.
  3. On return in the call made to parseTypedDeclaration(onlyType=true) by parseCast() we can then extract the typeString from the TypedEntity.
## Solution potentiale 2 ✅ > Okay, next thing though - it returns a `TypedEntity` and DOES expect an identifier. We may need to add a new flag to say `dontExpectIdentifier`. 1. Actually, just have a `onlyType=true`, then we stop there rather. 2. It returns a TypedEntity, so it needs a name? Perhaps we generate a bogus one with an empty identifier. 3. On return in the call made to `parseTypedDeclaration(onlyType=true)` by `parseCast()` we can then extract the _typeString_ from the `TypedEntity`.
deavmi changed reference from vardec_varass_dependency to casting 2023-04-14 12:32:37 +01:00
Author
Owner

Nous sommes en allent avec solution potentiale deux comme de commit 990b8a7d8721103d2181225ac5c6d40ee265a340 (tag: parsetypeddeclaration_onlytype_parsecast_new)

Nous sommes en allent avec solution potentiale deux comme de commit `990b8a7d8721103d2181225ac5c6d40ee265a340` (tag: `parsetypeddeclaration_onlytype_parsecast_new`)
deavmi added the
needsfix
label 2023-04-14 12:34:58 +01:00
deavmi added the due date 2023-04-14 2023-04-14 12:35:05 +01:00
deavmi changed title from parseType() to Casting improvement, parseTypedDeclaration() 2023-04-14 12:38:21 +01:00
Author
Owner

Merging this now to vardec_varass_dependency

Merging this now to `vardec_varass_dependency`
deavmi reopened this issue 2023-04-14 12:38:56 +01:00
deavmi added a new dependency 2023-04-14 12:38:59 +01:00
deavmi added a new dependency 2023-04-14 12:39:04 +01:00
deavmi reopened this issue 2023-04-14 12:46:12 +01:00
Author
Owner

Re-opened just because we should first test this - see how well it goes, then close it.

Re-opened just because we should first test this - see how well it goes, then close it.
Author
Owner

I should be able to close this soon, seems I was able to integrate this into both the arrays and pointers branch correctly.

I should be able to close this soon, seems I was able to integrate this into both the `arrays` and `pointers` branch correctly.
deavmi removed a dependency 2023-04-17 15:53:28 +01:00
Author
Owner

I believe this should be able to be closed when we are finished working on #81.

#87 is more long term

I believe this should be able to be closed when we are finished working on #81. #87 is more long term
deavmi added a new dependency 2023-04-20 10:20:24 +01:00
Author
Owner

I'm going to close this for now, we can always make a new issue later - it seems pretty good now (casting support that is).

Also closed #87

I'm going to close this for now, we can always make a new issue later - it seems pretty good now (casting support that is). Also closed #87
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

2023-04-14

Blocks
Reference: tlang/tlang#110
No description provided.