@@ -366,13 +366,23 @@ pSyntaxRule syn
366366 lchar '='
367367 tm <- pExpr syn
368368 pTerminator
369− return (Rule syms tm sty)
369+ return (Rule (mkSimple syms) tm sty)
370370 where
371371 expr (Expr _) = True
372372 expr _ = False
373373 name (Expr n) = Just n
374374 name _ = Nothing
375375
376+ -- Can't parse two full expressions (i.e. expressions with application) in a row
377+ -- so change the first to a simple expression
378+
379+ mkSimple (Expr e : es) = SimpleExpr e : mkSimple' es
380+ mkSimple xs = mkSimple' xs
381+
382+ mkSimple' (Expr e : Expr e1 : es) = SimpleExpr e : mkSimple' (Expr e1 : es)
383+ mkSimple' (e : es) = e : mkSimple' es
384+ mkSimple' [] = []
385+
376386pSynSym :: IParser SSymbol
377387pSynSym = try (do lchar '['; n <- pName; lchar ']'
378388 return (Expr n))
@@ -508,6 +518,7 @@ pSimpleExtExpr syn = do i <- getState
508518 pExtensions syn (filter simple (syntax_rules i))
509519 where
510520 simple (Rule (Expr x:xs) _ _) = False
521+ simple (Rule (SimpleExpr x:xs) _ _) = False
511522 simple (Rule [Keyword _] _ _) = True
512523 simple (Rule [Symbol _] _ _) = True
513524 simple (Rule (_:xs) _ _) = case (last xs) of
@@ -534,17 +545,18 @@ pExtensions syn rules = choice (map (\x -> try (pExt syn x)) (filter valid rules
534545
535546
536547pExt :: SyntaxInfo -> Syntax -> IParser PTerm
537−pExt syn (Rule (s:ssym) ptm _)
538− = do s1 <- pSymbol pSimpleExpr s
539− smap <- mapM (pSymbol pExpr) ssym
540− let ns = mapMaybe id (s1:smap)
548+pExt syn (Rule ssym ptm _)
549+ = do smap <- mapM pSymbol ssym
550+ let ns = mapMaybe id smap
541551 return (update ns ptm) -- updated with smap
542552 where
543− pSymbol p (Keyword n) = do reserved (show n); return Nothing
544− pSymbol p (Expr n) = do tm <- p syn
545− return $ Just (n, tm)
546− pSymbol p (Symbol s) = do symbol s
547− return Nothing
553+ pSymbol (Keyword n) = do reserved (show n); return Nothing
554+ pSymbol (Expr n) = do tm <- pExpr syn
555+ return $ Just (n, tm)
556+ pSymbol (SimpleExpr n) = do tm <- pSimpleExpr syn
557+ return $ Just (n, tm)
558+ pSymbol (Symbol s) = do symbol s
559+ return Nothing
548560 dropn n [] = []
549561 dropn n ((x,t) : xs) | n == x = xs
550562 | otherwise = (x,t):dropn n xs