aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorjohnvg2004-05-27 12:53:14 +0000
committerjohnvg2004-05-27 12:53:14 +0000
commit7accb952ea55d325e1e235c987c30ce7c18d0b56 (patch)
tree3f90a4043b3047b29030bc2c9be3aef5e6d9dc77 /frontend
parentconvert hfs file name to unix file name for freopen on MacOSX/MachO (diff)
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
Diffstat (limited to 'frontend')
-rw-r--r--frontend/parse.icl13
1 files changed, 8 insertions, 5 deletions
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 "<global definition>" 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 "<class or instance definition>" pState)
+ = (PD_NodeDef pos (combine_args args) rhs, parseError "RHS" No "<global definition>" 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