Skip to content

Commit 7431c83

Browse files
committed
Clean up parsing of Spin2 versioned keywords, and add some new ones
1 parent d880152 commit 7431c83

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

frontends/lexer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#define VT '\013'
2525

26-
#define MAX_PNUT_VERSION 44 /* maximum PNut version we understand */
26+
#define MAX_PNUT_VERSION 45 /* maximum PNut version we understand */
2727

2828
int allow_type_names = 1;
2929

@@ -790,11 +790,11 @@ parseSpinIdentifier(LexStream *L, AST **ast_ptr, const char *prefix)
790790
}
791791
}
792792
if (L->language == LANG_SPIN_SPIN2) {
793+
int userVersion = L->language_version;
793794
sym = NULL;
794-
if (gl_in_spin2_funcbody) {
795+
if (userVersion > 0 || gl_in_spin2_funcbody) {
795796
sym = FindSymbol(&spin2SoftReservedWords, idstr);
796797
if (sym) {
797-
int userVersion = L->language_version;
798798
int minVersion = sym->offset & 0xFFFF;
799799
int maxVersion = (sym->offset>>16) & 0xFFFF;
800800
int startline = L->lineCounter;
@@ -804,7 +804,7 @@ parseSpinIdentifier(LexStream *L, AST **ast_ptr, const char *prefix)
804804
sym = NULL;
805805
} else if (maxVersion && userVersion > maxVersion) {
806806
sym = NULL;
807-
} else {
807+
} else if (gl_in_spin2_funcbody) {
808808
// see if the user has a conflicting definition
809809
Symbol *sym2 = FindSymbolInContext(currentTypes, idstr);
810810
if (sym2) {

frontends/spin/spin.y

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,16 @@ funccall:
22002200
{
22012201
SYNTAX_ERROR("REGLOAD is not supported by flexspin");
22022202
}
2203+
| SP_SIZEOF '(' SP_TYPENAME ')'
2204+
{
2205+
AST *src = $3;
2206+
$$ = NewAST(AST_SIZEOF, src, NULL);
2207+
}
2208+
| SP_SIZEOF '(' expr ')'
2209+
{
2210+
AST *src = $3;
2211+
$$ = NewAST(AST_SIZEOF, src, NULL);
2212+
}
22032213
| SP_COPY '(' expr ',' expr ')'
22042214
{
22052215
AST *dst = $3;

0 commit comments

Comments
 (0)