1 ! Copyright (C) 2006 Chris Double. All Rights Reserved.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel tools.test peg fjsc ;
6 { T{ ast-expression f V{ T{ ast-number f 55 } T{ ast-identifier f "2abc1" } T{ ast-number f 100 } } } } [
7 "55 2abc1 100" 'expression' parse
10 { T{ ast-quotation f V{ T{ ast-number f 55 } T{ ast-identifier f "2abc1" } T{ ast-number f 100 } } } } [
11 "[ 55 2abc1 100 ]" 'quotation' parse
14 { T{ ast-array f V{ T{ ast-number f 55 } T{ ast-identifier f "2abc1" } T{ ast-number f 100 } } } } [
15 "{ 55 2abc1 100 }" 'array' parse
18 { T{ ast-stack-effect f V{ } V{ "d" "e" "f" } } } [
19 "( -- d e f )" 'stack-effect' parse
22 { T{ ast-stack-effect f V{ "a" "b" "c" } V{ "d" "e" "f" } } } [
23 "( a b c -- d e f )" 'stack-effect' parse
26 { T{ ast-stack-effect f V{ "a" "b" "c" } V{ } } } [
27 "( a b c -- )" 'stack-effect' parse
30 { T{ ast-stack-effect f V{ } V{ } } } [
31 "( -- )" 'stack-effect' parse
35 ": foo ( a b -- c d ) abcdefghijklmn 123 ;" 'expression' parse not
39 { T{ ast-expression f V{ T{ ast-string f "abcd" } } } } [
40 "\"abcd\"" 'statement' parse
43 { T{ ast-expression f V{ T{ ast-use f "foo" } } } } [
44 "USE: foo" 'statement' parse
47 { T{ ast-expression f V{ T{ ast-in f "foo" } } } } [
48 "IN: foo" 'statement' parse
51 { T{ ast-expression f V{ T{ ast-using f V{ "foo" "bar" } } } } } [
52 "USING: foo bar ;" 'statement' parse