From f0aa694c7e8f253aa0909585cd6655435798fcef Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 23 Feb 2010 23:57:13 +1300 Subject: [PATCH] effects.parser: throw a proper no-word error if effect references an unknown class word --- basis/macros/macros.factor | 6 +++--- basis/memoize/memoize.factor | 6 +++--- basis/peg/peg.factor | 6 +++--- basis/promises/promises.factor | 2 +- basis/typed/typed.factor | 2 +- core/effects/parser/parser.factor | 12 ++++++++---- core/parser/parser.factor | 7 +------ 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/basis/macros/macros.factor b/basis/macros/macros.factor index 91ca2f301c..9137588e6c 100644 --- a/basis/macros/macros.factor +++ b/basis/macros/macros.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: parser kernel sequences words effects combinators assocs -definitions quotations namespaces memoize accessors fry -compiler.units ; +USING: parser effects.parser kernel sequences words effects +combinators assocs definitions quotations namespaces memoize +accessors fry compiler.units ; IN: macros tuple-layout ; IN: typed diff --git a/core/effects/parser/parser.factor b/core/effects/parser/parser.factor index a77ea34c30..842d4f6447 100644 --- a/core/effects/parser/parser.factor +++ b/core/effects/parser/parser.factor @@ -1,7 +1,7 @@ -! Copyright (C) 2008, 2009 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: lexer sets sequences kernel splitting effects -combinators arrays vocabs.parser classes ; +combinators arrays vocabs.parser classes parser ; IN: effects.parser DEFER: parse-effect @@ -14,9 +14,8 @@ ERROR: bad-effect ; ":" ?tail [ scan { { [ dup "(" = ] [ drop ")" parse-effect ] } - { [ dup search class? ] [ search ] } { [ dup f = ] [ ")" unexpected-eof ] } - [ bad-effect ] + [ parse-word dup class? [ bad-effect ] unless ] } cond 2array ] when ] if @@ -36,3 +35,8 @@ ERROR: stack-effect-omits-dashes tokens ; : parse-call( ( accum word -- accum ) [ ")" parse-effect ] dip 2array append! ; + +: (:) ( -- word def effect ) + CREATE-WORD + complete-effect + parse-definition swap ; diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 544d75b244..e3e7d79c40 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -5,7 +5,7 @@ sequences strings vectors words words.symbol quotations io combinators sorting splitting math.parser effects continuations io.files vocabs io.encodings.utf8 source-files classes hashtables compiler.units accessors sets lexer vocabs.parser -effects.parser slots parser.notes ; + slots parser.notes ; IN: parser : location ( -- loc ) @@ -102,11 +102,6 @@ M: f parse-quotation \ ] parse-until >quotation ; : parse-definition ( -- quot ) \ ; parse-until >quotation ; -: (:) ( -- word def effect ) - CREATE-WORD - complete-effect - parse-definition swap ; - ERROR: bad-number ; : scan-base ( base -- n )