From 7accb952ea55d325e1e235c987c30ce7c18d0b56 Mon Sep 17 00:00:00 2001 From: johnvg Date: Thu, 27 May 2004 12:53:14 +0000 Subject: report a parse error if an instance definition contains a nodedef after 'where', instead of aborting in postparse git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@1498 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d --- frontend/parse.icl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'frontend') diff --git a/frontend/parse.icl b/frontend/parse.icl index b124307..7d2df1d 100644 --- a/frontend/parse.icl +++ b/frontend/parse.icl @@ -276,7 +276,7 @@ isGlobalContext parseContext :== parseContext bitand cGlobalContext <> 0 // not isDclContext parseContext :== parseContext bitand cICLContext == 0 isIclContext parseContext :== parseContext bitand cICLContext <> 0 // not (isDclContext parseContext) -isClassOrInstanceDefsContext parseContext :== parseContext bitand cClassOrInstanceDefsContext <> 0 +isNotClassOrInstanceDefsContext parseContext :== parseContext bitand cClassOrInstanceDefsContext == 0 isGlobalOrClassOrInstanceDefsContext parseContext :== parseContext bitand (cGlobalContext bitor cClassOrInstanceDefsContext) <> 0 cWantIclFile :== True @@ -528,9 +528,11 @@ where # (ss_useLayout, pState) = accScanState UseLayout pState localsExpected = ~ ss_useLayout (rhs, _, pState) = wantRhs localsExpected (ruleDefiningRhsSymbol parseContext) (tokenBack pState) - | isGlobalContext parseContext - = (PD_NodeDef pos (combine_args args) rhs, parseError "RHS" No "" pState) - = (PD_NodeDef pos (combine_args args) rhs, pState) + | isLocalContext parseContext + | isNotClassOrInstanceDefsContext parseContext + = (PD_NodeDef pos (combine_args args) rhs, pState) + = (PD_NodeDef pos (combine_args args) rhs, parseError "RHS" No "" pState) + = (PD_NodeDef pos (combine_args args) rhs, parseError "RHS" No "" pState) where want_node_def_token s EqualToken = s want_node_def_token s DefinesColonToken = s // PK replaceToken EqualToken s @@ -541,7 +543,7 @@ where want_rhs_of_def parseContext (Yes (name, False), []) definingToken pos pState # code_allowed = definingToken == EqualToken | isIclContext parseContext && isLocalContext parseContext && (definingToken == EqualToken || definingToken == DefinesColonToken) && - /* PK isLowerCaseName name.id_name && */ not (isClassOrInstanceDefsContext parseContext) + /* PK isLowerCaseName name.id_name && */ isNotClassOrInstanceDefsContext parseContext # (token, pState) = nextToken FunctionContext pState | code_allowed && token == CodeToken # (rhs, pState) = wantCodeRhs pState @@ -576,6 +578,7 @@ where FK_Caf | isNotEmpty args -> (PD_Function pos name is_infix [] rhs fun_kind, parseError "CAF" No "No arguments for a CAF" pState) _ -> (PD_Function pos name is_infix args rhs fun_kind, pState) + check_name_and_fixity No hasprio pState = (erroneousIdent, False, parseError "Definition" No "identifier" pState) check_name_and_fixity (Yes (name,is_infix)) hasprio pState -- cgit v1.2.3