factor: Add syntax.arity for new parser.
parent
516073cbd0
commit
2a19d0ca4e
|
@ -37,6 +37,7 @@ load-help? off
|
|||
"vocabs.loader" require
|
||||
|
||||
"syntax" require
|
||||
"syntax.arity" require
|
||||
"bootstrap.layouts" require
|
||||
|
||||
! need this
|
||||
|
|
|
@ -15,8 +15,8 @@ in: bootstrap.syntax
|
|||
"B{"
|
||||
"BV{"
|
||||
"C:"
|
||||
"CHAR:"
|
||||
"char:"
|
||||
"ARITY:"
|
||||
"DEFER:"
|
||||
"defer:"
|
||||
"ERROR:"
|
||||
|
@ -36,7 +36,6 @@ in: bootstrap.syntax
|
|||
"MATH:"
|
||||
"MIXIN:"
|
||||
"mixin:"
|
||||
"NAN:"
|
||||
"nan:"
|
||||
"POSTPONE\\"
|
||||
"postpone\\"
|
||||
|
@ -64,7 +63,7 @@ in: bootstrap.syntax
|
|||
"UNUSE:"
|
||||
"unuse:"
|
||||
"USING:"
|
||||
"qualified:"
|
||||
"QUALIFIED:"
|
||||
"qualified:"
|
||||
"QUALIFIED-WITH:"
|
||||
"FROM:"
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
! Copyright (C) 2016 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: ;
|
||||
in: syntax.arity
|
||||
|
||||
ARITY: \ IN: 1
|
||||
ARITY: \ USE: 1
|
||||
ARITY: \ UNUSE: 1
|
||||
ARITY: \ SYMBOL: 1
|
||||
ARITY: \ SINGLETON: 1
|
||||
ARITY: \ B: 1
|
||||
|
||||
|
||||
ARITY: \ ALIAS: 2
|
||||
ARITY: \ C: 2
|
||||
ARITY: \ CONSTANT: 2
|
||||
ARITY: \ INSTANCE: 2
|
||||
|
||||
ARITY: \ GENERIC: 2
|
||||
ARITY: \ PRIMITIVE: 2
|
||||
|
||||
|
||||
ARITY: \ GENERIC# 3
|
||||
ARITY: \ HOOK: 3
|
||||
|
|
@ -0,0 +1 @@
|
|||
Doug Coleman
|
|
@ -82,7 +82,7 @@ in: bootstrap.syntax
|
|||
|
||||
"USING:" [ ";" [ use-vocab ] each-token ] define-core-syntax
|
||||
|
||||
"qualified:" [ scan-token dup add-qualified ] define-core-syntax
|
||||
"QUALIFIED:" [ scan-token dup add-qualified ] define-core-syntax
|
||||
"qualified:" [ scan-token dup add-qualified ] define-core-syntax
|
||||
|
||||
"QUALIFIED-WITH:" [ scan-token scan-token ";" expect add-qualified ] define-core-syntax
|
||||
|
@ -99,19 +99,10 @@ in: bootstrap.syntax
|
|||
scan-token scan-token "=>" expect scan-token ";" expect add-renamed-word
|
||||
] define-core-syntax
|
||||
|
||||
"NAN:" [ 16 scan-base <fp-nan> suffix! ] define-core-syntax
|
||||
"nan:" [ 16 scan-base <fp-nan> suffix! ] define-core-syntax
|
||||
|
||||
"f" [ f suffix! ] define-core-syntax
|
||||
|
||||
"CHAR:" [
|
||||
lexer get parse-raw [ "token" throw-unexpected-eof ] unless* {
|
||||
{ [ dup length 1 = ] [ first ] }
|
||||
{ [ "\\" ?head ] [ next-escape >string "" assert= ] }
|
||||
[ name>char-hook get call( name -- char ) ]
|
||||
} cond suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"char:" [
|
||||
lexer get parse-raw [ "token" throw-unexpected-eof ] unless* {
|
||||
{ [ dup length 1 = ] [ first ] }
|
||||
|
@ -140,7 +131,6 @@ in: bootstrap.syntax
|
|||
"W{" [ \ } [ first <wrapper> ] parse-literal ] define-core-syntax
|
||||
"HS{" [ \ } [ >hash-set ] parse-literal ] define-core-syntax
|
||||
|
||||
"POSTPONE\\" [ scan-word suffix! ] define-core-syntax
|
||||
"postpone\\" [ scan-word suffix! ] define-core-syntax
|
||||
"\\" [ scan-word <wrapper> suffix! ] define-core-syntax
|
||||
"M\\" [ scan-word scan-word lookup-method <wrapper> suffix! ] define-core-syntax
|
||||
|
@ -189,6 +179,7 @@ in: bootstrap.syntax
|
|||
scan-token current-vocab create-word
|
||||
[ fake-definition ] [ set-last-word ] [ undefined-def define ] tri
|
||||
] define-core-syntax
|
||||
|
||||
"defer:" [
|
||||
scan-token current-vocab create-word
|
||||
[ fake-definition ] [ set-last-word ] [ undefined-def define ] tri
|
||||
|
@ -315,6 +306,10 @@ in: bootstrap.syntax
|
|||
[ current-source-file get [ main<< ] [ drop ] if* ] bi
|
||||
] define-core-syntax
|
||||
|
||||
"ARITY:" [
|
||||
scan-escaped-word scan-number "arity" set-word-prop
|
||||
] define-core-syntax
|
||||
|
||||
"<<" [
|
||||
[
|
||||
\ >> parse-until >quotation
|
||||
|
|
|
@ -8,34 +8,40 @@ in: alien.syntax
|
|||
|
||||
SYNTAX: \ DLL" lexer get skip-blank parse-string dlopen suffix! ;
|
||||
|
||||
SYNTAX: \ ALIEN: 16 scan-base <alien> suffix! ;
|
||||
SYNTAX: \ alien: 16 scan-base <alien> suffix! ;
|
||||
|
||||
SYNTAX: BAD-ALIEN <bad-alien> suffix! ;
|
||||
|
||||
SYNTAX: \ LIBRARY: scan-token current-library set ;
|
||||
ARITY: \ LIBRARY: 1
|
||||
SYNTAX: \ library: scan-token current-library set ;
|
||||
ARITY: \ library: 1
|
||||
|
||||
SYNTAX: \ FUNCTION:
|
||||
(FUNCTION:) make-function define-inline ;
|
||||
ARITY: \ FUNCTION: 4
|
||||
|
||||
SYNTAX: \ FUNCTION-ALIAS:
|
||||
scan-token create-function
|
||||
(FUNCTION:) (make-function) define-inline ;
|
||||
ARITY: \ FUNCTION-ALIAS: 4
|
||||
|
||||
SYNTAX: \ CALLBACK:
|
||||
(CALLBACK:) define-inline ;
|
||||
|
||||
SYNTAX: \ TYPEDEF:
|
||||
scan-c-type CREATE-C-TYPE ";" expect dup save-location typedef ;
|
||||
ARITY: \ TYPEDEF: 2
|
||||
|
||||
SYNTAX: \ ENUM:
|
||||
parse-enum (define-enum) ;
|
||||
|
||||
SYNTAX: \ C-TYPE:
|
||||
void CREATE-C-TYPE typedef ;
|
||||
ARITY: \ C-TYPE: 2
|
||||
SYNTAX: \ c-type:
|
||||
void CREATE-C-TYPE typedef ;
|
||||
ARITY: \ c-type: 2
|
||||
|
||||
SYNTAX: \ &:
|
||||
scan-token current-library get '[ _ _ address-of ] append! ;
|
||||
|
|
Loading…
Reference in New Issue