Skip to content

Commit

Permalink
Merge pull request #7 from n7space/feature-TMC#144-float-literal-as-c…
Browse files Browse the repository at this point in the history
…onst-token

fixed default Lextok val type
  • Loading branch information
Lurkerpas authored Sep 23, 2022
2 parents f1caa1b + ffacc66 commit 9385fc9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,8 @@ setaccess(Symbol *sp, Symbol *what, int cnt, int t)

Lextok *
nn(Lextok *s, int t, Lextok *ll, Lextok *rl)
{ Lextok *n = (Lextok *) emalloc(sizeof(Lextok));
{ Lextok *n = allocateLextok();

static int warn_nn = 0;

n->uiid = is_inline(); /* record origin of the statement */
Expand Down
2 changes: 2 additions & 0 deletions Src/spin.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ Lextok *rem_lab(Symbol *, Lextok *, Symbol *);
Lextok *rem_var(Symbol *, Lextok *, Symbol *, Lextok *);
Lextok *tail_add(Lextok *, Lextok *);
Lextok *return_statement(Lextok *);
Lextok *allocateLextok(void);


ProcList *mk_rdy(Symbol *, Lextok *, Sequence *, int, Lextok *, enum btypes);

Expand Down
8 changes: 8 additions & 0 deletions Src/spinlex.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ return_statement(Lextok *n)
return ZN;
}

Lextok *
allocateLextok(void)
{
Lextok* newLextokPtr = (Lextok *) emalloc(sizeof(Lextok));
newLextokPtr->constValKind = VALUE_INT;
return newLextokPtr;
}

static int
getinline(void)
{ int c;
Expand Down
2 changes: 1 addition & 1 deletion Src/structs.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ cpnn(Lextok *s, int L, int R, int S)

if (!s) return ZN;

d = (Lextok *) emalloc(sizeof(Lextok));
d = allocateLextok();
d->uiid = s->uiid;
d->ntyp = s->ntyp;
d->val = s->val;
Expand Down
2 changes: 1 addition & 1 deletion Src/sym.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ setxus(Lextok *p, int t)
fatal("non-local x[rs] assertion", (char *)0);
}
for (m = p; m; m = m->rgt)
{ Lextok *Xu_new = (Lextok *) emalloc(sizeof(Lextok));
{ Lextok *Xu_new = allocateLextok();
Xu_new->uiid = p->uiid;
Xu_new->val = t;
Xu_new->lft = m->lft;
Expand Down
4 changes: 2 additions & 2 deletions Src/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#ifndef SEEN_VALUE_H
#define SEEN_VALUE_H

/* Types of primitives held in Value type - test_loops fails if in other sequence - TODO - verify why */
typedef enum {VALUE_INT, VALUE_FLOAT} ValueKind;
/* Types of primitives held in Value type */
typedef enum { VALUE_FLOAT, VALUE_INT} ValueKind;

/* Variant type */
typedef struct {
Expand Down

0 comments on commit 9385fc9

Please sign in to comment.