diff --git a/demos/rosetta-code/arithmetic-evaluation/arithmetic-evaluation.factor b/demos/rosetta-code/arithmetic-evaluation/arithmetic-evaluation.factor index f8affe8ba1..090b9eb504 100644 --- a/demos/rosetta-code/arithmetic-evaluation/arithmetic-evaluation.factor +++ b/demos/rosetta-code/arithmetic-evaluation/arithmetic-evaluation.factor @@ -34,7 +34,7 @@ TUPLE: sub < operator ; C: sub ; TUPLE: mul < operator ; C: mul ; TUPLE: div < operator ; C:
div ; -EBNF: expr-ast +: expr-ast ( string -- obj ) EBNF{{ spaces = [\n\t ]* digit = [0-9] number = (digit)+ => [[ string>number ]] @@ -51,7 +51,7 @@ exp = exp:a spaces "+" fac:b => [[ a b ]] | fac main = exp:e spaces !(.) => [[ e ]] -EBNF; +}} ; GENERIC: eval-ast ( ast -- result ) ; diff --git a/demos/smalltalk/parser/parser-tests.factor b/demos/smalltalk/parser/parser-tests.factor index c46baf1ed8..ac61a5af75 100644 --- a/demos/smalltalk/parser/parser-tests.factor +++ b/demos/smalltalk/parser/parser-tests.factor @@ -3,15 +3,17 @@ USING: smalltalk.parser smalltalk.ast peg.ebnf tools.test accessors io.files io.encodings.ascii kernel ; -EBNF: test-Character -test = -EBNF; +: test-Character ( string -- obj ) + EBNF{{ + test = + }} ; { char: a } [ "a" test-Character ] unit-test -EBNF: test-Comment -test = -EBNF; +: test-Comment ( string -- obj ) + EBNF{{ + test = + }} ; { T{ ast-comment f "Hello, this is a comment." } } [ "\"Hello, this is a comment.\"" test-Comment ] @@ -21,15 +23,15 @@ unit-test [ "\"Hello, \"\"this\"\" is a comment.\"" test-Comment ] unit-test -EBNF: test-Identifier +: test-Identifier ( string -- obj ) EBNF{{ test = -EBNF; +}} ; { "OrderedCollection" } [ "OrderedCollection" test-Identifier ] unit-test -EBNF: test-Literal +: test-Literal ( string -- obj ) EBNF{{ test = -EBNF; +}} ; { nil } [ "nil" test-Literal ] unit-test { 123 } [ "123" test-Literal ] unit-test @@ -76,22 +78,22 @@ EBNF; } [ "[5. self]" test-Literal ] unit-test -EBNF: test-FormalBlockArgumentDeclarationList +: test-FormalBlockArgumentDeclarationList ( string -- obj ) EBNF{{ test = -EBNF; +}} ; { V{ "x" "y" "elt" } } [ ":x :y :elt" test-FormalBlockArgumentDeclarationList ] unit-test -EBNF: test-Operand +: test-Operand ( string -- obj ) EBNF{{ test = -EBNF; +}} ; { { 123 15.6 { t f } } } [ "#(123 15.6 (true false))" test-Operand ] unit-test { T{ ast-name f "x" } } [ "x" test-Operand ] unit-test -EBNF: test-Expression +: test-Expression ( string -- obj ) EBNF{{ test = -EBNF; +}} ; { self } [ "self" test-Expression ] unit-test { { 123 15.6 { t f } } } [ "#(123 15.6 (true false))" test-Expression ] unit-test @@ -227,17 +229,17 @@ EBNF; } [ "(#(['a']) at: 0) value" test-Expression ] unit-test -EBNF: test-FinalStatement +: test-FinalStatement ( string -- obj ) EBNF{{ test = -EBNF; +}} ; { T{ ast-name f "value" } } [ "value" test-FinalStatement ] unit-test { T{ ast-return f T{ ast-name f "value" } } } [ "^value" test-FinalStatement ] unit-test { T{ ast-assignment f T{ ast-name f "value" } 5 } } [ "value:=5" test-FinalStatement ] unit-test -EBNF: test-LocalVariableDeclarationList +: test-LocalVariableDeclarationList ( string -- obj ) EBNF{{ test = -EBNF; +}} ; { T{ ast-local-variables f { "i" "j" } } } [ " | i j |" test-LocalVariableDeclarationList ] unit-test diff --git a/demos/smalltalk/parser/parser.factor b/demos/smalltalk/parser/parser.factor index ed4d50f179..9b994f2845 100644 --- a/demos/smalltalk/parser/parser.factor +++ b/demos/smalltalk/parser/parser.factor @@ -13,7 +13,7 @@ ERROR: bad-number str ; : check-number ( str -- n ) >string dup string>number [ ] [ bad-number ] ?if ; -EBNF: parse-smalltalk +: parse-smalltalk ( string -- obj ) EBNF{{ Character = . WhitespaceCharacter = [ \t\n\r] @@ -225,4 +225,4 @@ End = !(.) Program = TopLevelForm End -EBNF; +}} ; diff --git a/demos/talks/galois-talk/galois-talk.factor b/demos/talks/galois-talk/galois-talk.factor index 66a598e370..40363b31ae 100644 --- a/demos/talks/galois-talk/galois-talk.factor +++ b/demos/talks/galois-talk/galois-talk.factor @@ -169,7 +169,7 @@ CONSTANT: galois-slides "Some parsing words are more complicated" } { $slide "Example: printf" - { { $link postpone\ EBNF: } ": a complex parsing word" } + { { $link \ EBNF{{ } ": a complex parsing word" } "Implements a custom syntax for expressing parsers: like OMeta!" { "Example: " { $vocab-link "printf-example" } } { $code "\"vegan\" \"cheese\" \"%s is not %s\\n\" printf" } diff --git a/demos/talks/google-tech-talk/google-tech-talk.factor b/demos/talks/google-tech-talk/google-tech-talk.factor index b0f8d427be..e0ea82830f 100644 --- a/demos/talks/google-tech-talk/google-tech-talk.factor +++ b/demos/talks/google-tech-talk/google-tech-talk.factor @@ -332,7 +332,7 @@ CONSTANT: google-slides "Some parsing words are more complicated" } { $slide "Parser expression grammars" - { { $link postpone\ EBNF: } ": a complex parsing word" } + { { $link postpone\ EBNF{{ } ": a complex parsing word" } "Implements a custom syntax for expressing parsers" { "Example: " { $vocab-link "printf-example" } } { $code "\"vegan\" \"cheese\" \"%s is not %s\\n\" printf" } diff --git a/demos/talks/vpri-talk/vpri-talk.factor b/demos/talks/vpri-talk/vpri-talk.factor index 6619f7ed02..16e93f14a1 100644 --- a/demos/talks/vpri-talk/vpri-talk.factor +++ b/demos/talks/vpri-talk/vpri-talk.factor @@ -189,7 +189,7 @@ CONSTANT: vpri-slides "Some parsing words are more complicated" } { $slide "Example: printf" - { { $link postpone\ EBNF: } ": a complex parsing word" } + { { $link postpone\ EBNF{{ } ": a complex parsing word" } "Implements a custom syntax for expressing parsers: like OMeta!" { "Example: " { $vocab-link "printf-example" } } { $code "\"vegan\" \"cheese\" \"%s is not %s\\n\" printf" } diff --git a/frameworks/db/postgresql/errors/errors.factor b/frameworks/db/postgresql/errors/errors.factor index 026c08e0ab..549f9354c4 100644 --- a/frameworks/db/postgresql/errors/errors.factor +++ b/frameworks/db/postgresql/errors/errors.factor @@ -5,7 +5,7 @@ combinators.short-circuit accessors math.parser quoting locals ; in: db.postgresql.errors -EBNF: parse-postgresql-sql-error +: parse-postgresql-sql-error ( string -- obj ) EBNF{{ Error = "ERROR:" [ ]+ @@ -35,18 +35,18 @@ UnknownError = .* => [[ >string ]] PostgresqlSqlError = (TableError | DatabaseError | FunctionError | SyntaxError | UnknownError) -EBNF; +}} ; TUPLE: parse-postgresql-location column line text ; C: parse-postgresql-location ; -EBNF: parse-postgresql-line-error +: parse-postgresql-line-error ( string -- obj ) EBNF{{ Line = "LINE " [0-9]+:line ": " .+:sql => [[ f line >string string>number sql >string ]] -EBNF; +}} ; :: set-caret-position ( error caret-line -- error ) caret-line length diff --git a/frameworks/db/sqlite/errors/errors.factor b/frameworks/db/sqlite/errors/errors.factor index c652eb5117..33270bdf1d 100644 --- a/frameworks/db/sqlite/errors/errors.factor +++ b/frameworks/db/sqlite/errors/errors.factor @@ -14,7 +14,7 @@ SINGLETONS: table-exists table-missing ; { table-exists [ ] } } case ; -EBNF: parse-sqlite-sql-error +: parse-sqlite-sql-error ( string -- obj ) EBNF{{ TableMessage = " already exists" => [[ table-exists ]] @@ -25,4 +25,4 @@ SqliteError = => [[ table >string ]] | .*:error => [[ error >string ]] -EBNF; +}} ; diff --git a/language/compiler/tests/peg-regression-2.factor b/language/compiler/tests/peg-regression-2.factor index ea7449a02a..f1206892b4 100644 --- a/language/compiler/tests/peg-regression-2.factor +++ b/language/compiler/tests/peg-regression-2.factor @@ -4,12 +4,12 @@ in: compiler.tests.peg-regression-2 GENERIC: ( times -- term' ) ; M: string ; -EBNF: parse-regexp +: parse-regexp ( string -- obj ) EBNF{{ Times = .* => [[ "foo" ]] Regexp = Times:t => [[ t ]] -EBNF; +}} ; [ "foo" ] [ "a" parse-regexp ] unit-test diff --git a/language/compiler/tests/peg-regression.factor b/language/compiler/tests/peg-regression.factor index ec91e81e5c..c8516327ba 100644 --- a/language/compiler/tests/peg-regression.factor +++ b/language/compiler/tests/peg-regression.factor @@ -16,9 +16,9 @@ M: pipeline-expr blah ; : ast>pipeline-expr ( -- obj ) pipeline-expr new blah ; -EBNF: expr +: expr ( string -- obj ) EBNF{{ pipeline = "hello" => [[ ast>pipeline-expr ]] -EBNF; +}} ; use: tools.test diff --git a/language/peg/ebnf/ebnf-docs.factor b/language/peg/ebnf/ebnf-docs.factor index 9fc5cc257e..d272f38872 100644 --- a/language/peg/ebnf/ebnf-docs.factor +++ b/language/peg/ebnf/ebnf-docs.factor @@ -38,26 +38,6 @@ HELP: EBNF{{ } } ; -HELP: EBNF: -{ $syntax "EBNF: word ...ebnf... EBNF;" } -{ $values { "word" word } { "...ebnf..." "EBNF DSL text" } } -{ $description - "Defines a word that when called will parse a string using the syntax " - "defined with the EBNF DSL. The word has stack effect " - { $snippet "( string -- ast )" } " where 'string' is the text to be parsed " - "and 'ast' is the resulting abstract syntax tree. If the parsing fails the " - "word throws an exception." -} -{ $examples - { $example - "USING: prettyprint peg.ebnf ;" - "in: scratchpad" - "EBNF: foo rule=\"a\" \"b\" EBNF;" - "\"ab\" foo ." - "V{ \"a\" \"b\" }" - } -} ; - ARTICLE: "peg.ebnf.strings" "EBNF Rule: Strings" "A string in a rule will match that sequence of characters from the input string. " "The string is delimited by matching single or double quotes. " @@ -338,22 +318,22 @@ ARTICLE: "peg.ebnf.foreign-rules" "EBNF Foreign Rules" { $examples { $code "USING: prettyprint peg.ebnf ;" - "EBNF: parse-string" + ": parse-string ( string -- obj ) EBNF{{" "StringBody = (!('\"') .)*" "String= '\"' StringBody:b '\"' => [[ b >string ]]" - "EBNF;" - "EBNF: parse-two-strings" + "}} ;" + ": parse-two-strings ( string -- obj ) EBNF{{" "TwoStrings = " - "EBNF;" - "EBNF: parse-two-strings" + "}} ;" + ": parse-two-strings ( string -- obj ) EBNF{{" "TwoString = " - "EBNF;" + "}} ;" } { $code ": a-token ( -- parser ) \"a\" token ;" - "EBNF: parse-abc" + ": parse-abc ( string -- obj ) EBNF{{" "abc = 'b' 'c'" - "EBNF;" + "}} ;" } } ; @@ -364,9 +344,9 @@ ARTICLE: "peg.ebnf.tokenizers" "EBNF Tokenizers" "Terminals in a rule match successive characters in the array or string. " { $examples { $code - "EBNF: foo" + ": foo ( string -- obj ) EBNF{{" "rule = \"++\" \"--\"" - "EBNF;" + "}} ;" } } "This parser when run with the string \"++--\" or the array " @@ -375,11 +355,11 @@ ARTICLE: "peg.ebnf.tokenizers" "EBNF Tokenizers" "between the terminals:" { $examples { $code - "EBNF: foo" + ": foo ( string -- obj ) EBNF{{" "space = (\" \" | \"\\r\" | \"\\t\" | \"\\n\")" "spaces = space* => [[ drop ignore ]]" "rule = spaces \"++\" spaces \"--\" spaces" - "EBNF;" + "}} ;" } } "In a large grammar this gets tedious and makes the grammar hard to read. " @@ -388,12 +368,12 @@ ARTICLE: "peg.ebnf.tokenizers" "EBNF Tokenizers" "might look:" { $examples { $code - "EBNF: foo" + ": foo ( string -- obj ) EBNF{{" "space = (\" \" | \"\\r\" | \"\\t\" | \"\\n\")" "spaces = space* => [[ drop ignore ]]" "tokenizer = spaces ( \"++\" | \"--\" )" "rule = \"++\" \"--\"" - "EBNF;" + "}} ;" } } "'tokenizer' is the name of a built in rule. Once defined it is called to " @@ -418,7 +398,7 @@ $nl "TUPLE: ast-number value ;" "TUPLE: ast-string value ;" "" - "EBNF: foo-tokenizer" + ": foo-tokenizer ( string -- obj ) EBNF{{" "space = (\" \" | \"\\r\" | \"\\t\" | \"\\n\")" "spaces = space* => [[ drop ignore ]]" "" @@ -427,16 +407,16 @@ $nl "" "token = spaces ( number | operator )" "tokens = token*" - "EBNF;" + "}} ; @ebnf" "" - "EBNF: foo" + ": foo ( string -- obj ) EBNF{{" "tokenizer = " "" "number = . ?[ ast-number? ]? => [[ value>> ]]" "string = . ?[ ast-string? ]? => [[ value>> ]]" "" "rule = string:a number:b \"+\" number:c => [[ a b c + 2array ]]" - "EBNF;" + "}} ;" "" "\"123 456 +\" foo-tokenizer ." "V{\n T{ ast-number { value 123 } }\n T{ ast-number { value 456 } }\n \"+\"\n}" @@ -453,7 +433,7 @@ $nl "was defined lexically before the rule. This is useful in the JavaScript grammar:" { $examples { $code - "EBNF: javascript" + ": javascript ( string -- obj ) EBNF{{" "tokenizer = default" "nl = \"\\r\" \"\\n\" | \"\\n\"" "tokenizer = " @@ -491,7 +471,6 @@ ARTICLE: "peg.ebnf" "EBNF" { $subsections \ EBNF< \ EBNF{{ - \ EBNF: } "The EBNF syntax is composed of a series of rules of the form:" { $code diff --git a/language/peg/ebnf/ebnf-tests.factor b/language/peg/ebnf/ebnf-tests.factor index 58c69fc420..5347259e3c 100644 --- a/language/peg/ebnf/ebnf-tests.factor +++ b/language/peg/ebnf/ebnf-tests.factor @@ -287,7 +287,7 @@ in: peg.ebnf.tests "abcd='9' | ('8'):x => [[ x ]]" ebnf-parser (parse) remaining>> empty? ] unit-test -EBNF: primary +: primary ( string -- obj ) EBNF{{ Primary = PrimaryNoNewArray PrimaryNoNewArray = ClassInstanceCreationExpression | MethodInvocation @@ -310,7 +310,7 @@ MethodName = "m" | "n" ExpressionName = Identifier Expression = "i" | "j" main = Primary -EBNF; +}} ; { "this" } [ "this" primary @@ -469,22 +469,22 @@ EBNF; ] unit-test << -EBNF: parser1 +: parser1 ( string -- obj ) EBNF{{ foo='a' -EBNF; +}} ; >> -EBNF: parser2 +: parser2 ( string -- obj ) EBNF{{ foo= 'b' -EBNF; +}} ; -EBNF: parser3 +: parser3 ( string -- obj ) EBNF{{ foo= 'c' -EBNF; +}} ; -EBNF: parser4 +: parser4 ( string -- obj ) EBNF{{ foo= 'd' -EBNF; +}} ; { "a" } [ "a" parser1 @@ -523,7 +523,7 @@ EBNF; TUPLE: ast-number value ; -EBNF: a-tokenizer +: a-tokenizer ( string -- obj ) EBNF{{ Letter = [a-zA-Z] Digit = [0-9] Digits = Digit+ @@ -539,7 +539,7 @@ Special = "(" | ")" | "{" | "}" | "[" | "]" | "," | " | "-" | "*=" | "*" | "/=" | "/" | "%=" | "%" | "&&=" | "&&" | "||=" | "||" | "." | "!" Tok = Spaces (Number | Special ) -EBNF; +}} ; { V{ char: 1 T{ ast-number f 23 } ";" char: x } } [ "123;x" EBNF{{ bar = . @@ -592,13 +592,17 @@ EBNF; { { "a" "a" } } [ - EBNF: foo Bar = "a":a1 "a":a2 => [[ a1 a2 2array ]] EBNF; + : foo ( string -- obj ) EBNF{{ + Bar = "a":a1 "a":a2 => [[ a1 a2 2array ]] + }} ; "aa" foo ] unit-test { { "a" "a" } } [ - EBNF: foo2 Bar = "a":a-1 "a":a-2 => [[ a-1 a-2 2array ]] EBNF; + : foo2 ( string -- obj ) EBNF{{ + Bar = "a":a-1 "a":a-2 => [[ a-1 a-2 2array ]] + }} ; "aa" foo2 ] unit-test diff --git a/language/peg/ebnf/ebnf.factor b/language/peg/ebnf/ebnf.factor index 3551d25b10..65f6d2b1b6 100644 --- a/language/peg/ebnf/ebnf.factor +++ b/language/peg/ebnf/ebnf.factor @@ -552,3 +552,6 @@ SYNTAX: \ EBNF: ebnf>quot swapd ( input -- ast ) define-declared "ebnf-parser" set-word-prop reset-tokenizer ; + +SYNTAX: @ebnf + words:last-word dup "ebnf-parser" set-word-prop ; \ No newline at end of file diff --git a/libs/formatting/formatting.factor b/libs/formatting/formatting.factor index 0afe1e63f7..8900171c30 100644 --- a/libs/formatting/formatting.factor +++ b/libs/formatting/formatting.factor @@ -37,7 +37,7 @@ in: formatting ERROR: unknown-printf-directive ; -EBNF: parse-printf +: parse-printf ( string -- obj ) EBNF{{ zero = "0" => [[ char: 0 ]] char = "'" (.) => [[ second ]] @@ -90,7 +90,7 @@ plain-text = (!("%").)+ => [[ >string ]] text = (formats|plain-text)* => [[ ]] -EBNF; +}} ; : printf-quot ( format-string -- format-quot n ) parse-printf [ [ callable? ] count ] keep [ @@ -155,7 +155,7 @@ MACRO: sprintf ( format-string -- quot ) : week-of-year-monday ( timestamp -- n ) 1 week-of-year ; inline -EBNF: parse-strftime +: parse-strftime ( string -- obj ) EBNF{{ fmt-% = "%" => [[ "%" ]] fmt-a = "a" => [[ [ day-of-week day-abbreviation3 ] ]] @@ -191,7 +191,7 @@ plain-text = (!("%").)+ => [[ >string ]] text = (formats|plain-text)* => [[ ]] -EBNF; +}} ; PRIVATE> diff --git a/libs/globs/globs.factor b/libs/globs/globs.factor index 75af0737d3..7e87e34273 100644 --- a/libs/globs/globs.factor +++ b/libs/globs/globs.factor @@ -12,7 +12,7 @@ in: globs : wild-path-separator ( -- sep ) os windows? R/ [^\\/\\][\\/\\]|[^\\/\\]/ R/ [^\\/][\\/]|[^\\/]/ ? ; foldable -EBNF: +: ( string -- obj ) EBNF{{ Character = "\\" .:c => [[ c 1string ]] | !(","|"}") . => [[ 1string ]] @@ -45,7 +45,7 @@ End = !(.) Main = Concatenation End -EBNF; +}} ; : glob-matches? ( input glob -- ? ) [ >case-fold ] bi@ matches? ; diff --git a/libs/gml/parser/parser.factor b/libs/gml/parser/parser.factor index 7a8fb5c21d..2bd817f5d3 100644 --- a/libs/gml/parser/parser.factor +++ b/libs/gml/parser/parser.factor @@ -52,7 +52,7 @@ ERROR: bad-vector-length seq n ; [ bad-vector-length ] } case ; -EBNF: parse-gml +: parse-gml ( string -- obj ) EBNF{{ Letter = [a-zA-Z] Digit = [0-9] @@ -124,4 +124,4 @@ Tokens = Token* => [[ [ comment? ] reject ]] Program = Tokens Spaces !(.) => [[ parse-proc ]] -EBNF; +}} ; diff --git a/libs/infix/parser/parser.factor b/libs/infix/parser/parser.factor index 25a2ae6a40..2c802d4df9 100644 --- a/libs/infix/parser/parser.factor +++ b/libs/infix/parser/parser.factor @@ -4,7 +4,7 @@ USING: infix.ast infix.tokenizer kernel math peg.ebnf sequences strings vectors ; in: infix.parser -EBNF: parse-infix +: parse-infix ( string -- obj ) EBNF{{ Number = . ?[ ast-number? ]? Identifier = . ?[ string? ]? Array = Identifier:i "[" Sum:s "]" => [[ i s ast-array boa ]] @@ -29,7 +29,7 @@ Sum = Sum:s ("+"|"-"):op Product:p => [[ s p op ast-op boa ]] End = !(.) Expression = Sum End -EBNF; +}} ; : build-infix-ast ( string -- ast ) tokenize-infix parse-infix ; diff --git a/libs/infix/tokenizer/tokenizer.factor b/libs/infix/tokenizer/tokenizer.factor index c83657dfcc..f75bdc050c 100644 --- a/libs/infix/tokenizer/tokenizer.factor +++ b/libs/infix/tokenizer/tokenizer.factor @@ -4,7 +4,7 @@ USING: infix.ast kernel peg peg.ebnf math.parser sequences strings ; in: infix.tokenizer -EBNF: tokenize-infix +: tokenize-infix ( string -- obj ) EBNF{{ Letter = [a-zA-Z] Digit = [0-9] Digits = Digit+ @@ -21,4 +21,4 @@ Special = [+*/%(),] | "-" => [[ char: - ]] Tok = Spaces (Name | Number | Special ) End = !(.) Toks = Tok* Spaces End -EBNF; +}} ; diff --git a/libs/peg/expr/expr.factor b/libs/peg/expr/expr.factor index 489832aeec..11861de6f5 100644 --- a/libs/peg/expr/expr.factor +++ b/libs/peg/expr/expr.factor @@ -4,7 +4,7 @@ USING: kernel arrays strings math.parser sequences peg peg.ebnf peg.parsers memoize math accessors ; in: peg.expr -EBNF: expr +: expr ( string -- obj ) EBNF{{ number = ([0-9])+ => [[ string>number ]] value = number | ("(" exp ")") => [[ second ]] @@ -16,4 +16,4 @@ fac = fac "*" value => [[ first3 nip * ]] exp = exp "+" fac => [[ first3 nip + ]] | exp "-" fac => [[ first3 nip - ]] | fac -EBNF; +}} ; diff --git a/libs/peg/javascript/parser/parser.factor b/libs/peg/javascript/parser/parser.factor index d2cece8f9c..937cff6fc0 100644 --- a/libs/peg/javascript/parser/parser.factor +++ b/libs/peg/javascript/parser/parser.factor @@ -18,7 +18,7 @@ in: peg.javascript.parser ! This operates a character at a time. Using this 'nl' in the parser ! allows us to detect newlines when we need to for the semicolon ! insertion rule, but ignore it in all other places. -EBNF: javascript +: javascript ( string -- obj ) EBNF{{ tokenizer = default nl = "\r\n" | "\n" @@ -197,4 +197,4 @@ SrcElem = "function" Name:n FuncRest:f => [[ n f a | Stmt SrcElems = SrcElem* => [[ ast-begin boa ]] TopLevel = SrcElems Spaces -EBNF; +}} ; diff --git a/libs/peg/javascript/tokenizer/tokenizer.factor b/libs/peg/javascript/tokenizer/tokenizer.factor index 8c11093778..b729c6dbf3 100644 --- a/libs/peg/javascript/tokenizer/tokenizer.factor +++ b/libs/peg/javascript/tokenizer/tokenizer.factor @@ -8,7 +8,7 @@ in: peg.javascript.tokenizer use: prettyprint -EBNF: tokenize-javascript +: tokenize-javascript ( string -- obj ) EBNF{{ Letter = [a-zA-Z] Digit = [0-9] Digits = Digit+ @@ -87,4 +87,4 @@ Special = "(" | ")" | "{" | "}" | "[" | "]" | "," | | "^" Tok = Spaces (Name | Keyword | Number | Str | RegExp | Special ) Toks = Tok* Spaces -EBNF; +}} ; diff --git a/libs/peg/pl0/pl0.factor b/libs/peg/pl0/pl0.factor index e892b34bd1..35bea3f1c7 100644 --- a/libs/peg/pl0/pl0.factor +++ b/libs/peg/pl0/pl0.factor @@ -6,7 +6,7 @@ in: peg.pl0 ! Grammar for PL/0 based on http://en.wikipedia.org/wiki/PL/0 -EBNF: pl0 +: pl0 ( string -- obj ) EBNF{{ block = { "CONST" ident "=" number { "," ident "=" number }* ";" }? { "VAR" ident { "," ident }* ";" }? @@ -24,4 +24,4 @@ factor = ident | number | "(" expression ")" ident = (([a-zA-Z])+) => [[ >string ]] number = ([0-9])+ => [[ string>number ]] program = { block "." } -EBNF; +}} ; diff --git a/libs/regexp/parser/parser.factor b/libs/regexp/parser/parser.factor index 8e83ce2add..f45c6e71cc 100644 --- a/libs/regexp/parser/parser.factor +++ b/libs/regexp/parser/parser.factor @@ -126,7 +126,7 @@ ERROR: nonexistent-option name ; ! add greedy and nongreedy forms of matching ! (once it's all implemented) -EBNF: parse-regexp +: parse-regexp ( string -- obj ) EBNF{{ CharacterInBracket = !("}") Character @@ -217,4 +217,4 @@ Alternation = Concatenation:c ("|" Concatenation)*:a End = !(.) Main = Alternation End -EBNF; +}} ; diff --git a/libs/shell/parser/parser.factor b/libs/shell/parser/parser.factor index 8569949e69..86ed76cfdb 100644 --- a/libs/shell/parser/parser.factor +++ b/libs/shell/parser/parser.factor @@ -41,7 +41,7 @@ TUPLE: factor-expr expr ; : ast>factor-expr ( ast -- obj ) second >string factor-expr boa ; -EBNF: expr +: expr ( string -- obj ) EBNF{{ space = " " @@ -89,4 +89,4 @@ pipeline = _ command _ (in-file)? _ "|" _ (command _ "|" _)* command _ (to-file submission = (pipeline | basic) -EBNF; +}} ; diff --git a/libs/simple-tokenizer/simple-tokenizer.factor b/libs/simple-tokenizer/simple-tokenizer.factor index a2c55fdf82..34af8d14df 100644 --- a/libs/simple-tokenizer/simple-tokenizer.factor +++ b/libs/simple-tokenizer/simple-tokenizer.factor @@ -3,11 +3,11 @@ USING: peg.ebnf strings ; in: simple-tokenizer -EBNF: tokenize +: tokenize ( string -- obj ) EBNF{{ space = [ \t\n\r] escaped-char = "\\" .:ch => [[ ch ]] quoted = '"' (escaped-char | [^"])*:a '"' => [[ a ]] unquoted = (escaped-char | [^ \t\n\r"])+ argument = (quoted | unquoted) => [[ >string ]] command = space* (argument:a space* => [[ a ]])+:c !(.) => [[ c ]] -EBNF; +}} ; diff --git a/libs/svg/svg.factor b/libs/svg/svg.factor index 620f076d65..9be697fb82 100644 --- a/libs/svg/svg.factor +++ b/libs/svg/svg.factor @@ -96,7 +96,7 @@ TUPLE: elliptical-arc radii x-axis-rotation large-arc? sweep? p relative? ; : (set-relative) ( args rel -- args ) '[ [ _ >>relative? drop ] each ] keep ; -EBNF: svg-path>array +: svg-path>array ( string -- obj ) EBNF{{ moveto-drawto-command-groups = moveto-drawto-command-group:first wsp* moveto-drawto-command-groups:rest @@ -219,7 +219,7 @@ wsp = [ \t\r\n] svg-path = wsp* moveto-drawto-command-groups?:x wsp* => [[ x ]] -EBNF; +}} ; : tag-d ( tag -- d ) "d" svg-name attr svg-path>array ; diff --git a/modern-transition.factor b/modern-transition.factor index 5a7447a99c..87fc5bf342 100644 --- a/modern-transition.factor +++ b/modern-transition.factor @@ -17,12 +17,10 @@ [ dup . flush vocab>literals ] map-zip "resource:libs" vocabs-from -{ "brainfuck" "metar" "svg" -"gml.parser" "infix.tokenizer" -"math.blas.matrices" "math.blas.vectors" +{ "metar" + "math.blas.matrices" "math.blas.vectors" "math.vectors.simd" "math.vectors.simd.cords" -"peg.pl0" "peg.javascript.parser" "peg.javascript.tokenizer" -"yaml.conversion" + "yaml.conversion" } diff [ dup . flush vocab>literals ] map-zip diff --git a/unmaintained/alien/inline/types/types.factor b/unmaintained/alien/inline/types/types.factor index 2d66810ded..b72c5ed57f 100644 --- a/unmaintained/alien/inline/types/types.factor +++ b/unmaintained/alien/inline/types/types.factor @@ -65,7 +65,7 @@ MEMO: resolved-primitives ( -- seq ) TUPLE: c++-type name params ptr ; C: c++-type ; -EBNF: (parse-c++-type) +: (parse-c++-type) ( string -- obj ) EBNF{{ dig = [0-9] alpha = [a-zA-Z] alphanum = [1-9a-zA-Z] @@ -77,7 +77,7 @@ param = "," " "* type " "* => [[ third ]] params = "<" " "* type " "* param* ">" => [[ [ 4 swap nth ] [ third ] bi prefix ]] type = name " "* params? " "* ptr? => [[ { 0 2 4 } [ swap nth ] with map first3 ]] -EBNF; +}} ; : parse-c++-type ( str -- c++-type ) factorize-type (parse-c++-type) ; diff --git a/unmaintained/llvm/types/types.factor b/unmaintained/llvm/types/types.factor index 123c08a5e9..a5a119dbd3 100644 --- a/unmaintained/llvm/types/types.factor +++ b/unmaintained/llvm/types/types.factor @@ -206,7 +206,7 @@ M: up-ref (>tref) [ LLVMDumpModule ] [ LLVMDisposeModule ] tri ; -EBNF: parse-type +: parse-type ( string -- obj ) EBNF{{ WhiteSpace = " "* @@ -241,6 +241,6 @@ Type = WhiteSpace T:t WhiteSpace => [[ t ]] Program = Type -EBNF; +}} ; -SYNTAX: TYPE: ";" parse-multiline-string parse-type suffix! ; +SYNTAX: \ TYPE: ";" parse-multiline-string parse-type suffix! ; diff --git a/unmaintained/modules/using/using.factor b/unmaintained/modules/using/using.factor index 4b2c18f944..6549548f5f 100644 --- a/unmaintained/modules/using/using.factor +++ b/unmaintained/modules/using/using.factor @@ -4,13 +4,13 @@ USING: kernel modules.rpc peg peg-lexer peg.ebnf sequences strings vocabs.parser ; in: modules.using -EBNF: modulize +: modulize ( string -- obj ) EBNF{{ tokenpart = (!(':').)+ => [[ >string ]] s = ':' => [[ drop ignore ]] rpc = tokenpart s s tokenpart => [[ first2 remote-vocab ]] remote = tokenpart s tokenpart => [[ first2 remote-load ]] module = rpc | remote | tokenpart -EBNF; +}} ; ON-BNF: USING*: tokenizer = @@ -25,4 +25,4 @@ long = "{" ( from | exclude | rename | qualified-with | qualified ) "}" => [[ dr short = modspec => [[ use-vocab ignore ]] wordSpec = long | short using = wordSpec+ ";" => [[ drop ignore ]] -;ON-BNF +ON-BNF; diff --git a/unmaintained/peg-lexer/peg-lexer-docs.factor b/unmaintained/peg-lexer/peg-lexer-docs.factor index 84e3b9d230..761842a8d3 100644 --- a/unmaintained/peg-lexer/peg-lexer-docs.factor +++ b/unmaintained/peg-lexer/peg-lexer-docs.factor @@ -1,9 +1,9 @@ USING: peg.ebnf help.syntax help.markup strings ; in: peg-lexer -HELP: ON-BNF: -{ $syntax "ON-BNF: word ... ;ON-BNF" } -{ $description "Creates a parsing word using a parser for lexer control, adding the resulting ast to the stack. Parser syntax is as in " { $link postpone\ EBNF: } } ; +HELP: \ ON-BNF: +{ $syntax "ON-BNF: word ... ON-BNF;" } +{ $description "Creates a parsing word using a parser for lexer control, adding the resulting ast to the stack. Parser syntax is as in " { $link postpone\ EBNF{{ } } ; HELP: create-bnf { $values { "name" string } { "parser" parser } } diff --git a/unmaintained/peg-lexer/peg-lexer.factor b/unmaintained/peg-lexer/peg-lexer.factor index ebe0c0e84e..43d69562e9 100644 --- a/unmaintained/peg-lexer/peg-lexer.factor +++ b/unmaintained/peg-lexer/peg-lexer.factor @@ -56,9 +56,9 @@ SYNTAX: ON-BNF: main of create-bnf ; ! Tokenizer like standard factor lexer -EBNF: factor +: factor ( string -- obj ) EBNF{{ space = " " | "\n" | "\t" spaces = space* => [[ drop ignore ]] chunk = (!(space) .)+ => [[ >string ]] expr = spaces chunk -EBNF; +}} ;