diff --git a/Rakefile b/Rakefile index 770ce79..63b905b 100755 --- a/Rakefile +++ b/Rakefile @@ -60,11 +60,11 @@ desc "Build meta files for ABNF, EBNF and ISO EBNF" task :meta => %w{lib/ebnf/ebnf/meta.rb lib/ebnf/isoebnf/meta.rb lib/ebnf/abnf/meta.rb lib/ebnf/abnf/core.rb} file "lib/ebnf/abnf/meta.rb" => "etc/abnf.ebnf" do - %x(bin/ebnf --input-format native --peg -f rb --mod-name ABNFMeta -o lib/ebnf/abnf/meta.rb etc/abnf.ebnf) + %x(bin/ebnf --peg -f rb --mod-name ABNFMeta -o lib/ebnf/abnf/meta.rb etc/abnf.ebnf) end file "lib/ebnf/abnf/core.rb" => "etc/abnf-core.ebnf" do - %x(bin/ebnf --input-format native -f rb --mod-name ABNFCore -o lib/ebnf/abnf/core.rb etc/abnf-core.ebnf) + %x(bin/ebnf -f rb --mod-name ABNFCore -o lib/ebnf/abnf/core.rb etc/abnf-core.ebnf) end file "lib/ebnf/ebnf/meta.rb" => "etc/ebnf.peg.rb" do @@ -72,7 +72,7 @@ file "lib/ebnf/ebnf/meta.rb" => "etc/ebnf.peg.rb" do end file "lib/ebnf/isoebnf/meta.rb" => "etc/iso-ebnf.ebnf" do - %x(bin/ebnf --input-format native --peg -f rb --mod-name ISOEBNFMeta -o lib/ebnf/isoebnf/meta.rb etc/iso-ebnf.ebnf) + %x(bin/ebnf --peg -f rb --mod-name ISOEBNFMeta -o lib/ebnf/isoebnf/meta.rb etc/iso-ebnf.ebnf) end @@ -80,7 +80,7 @@ end rule ".sxp" => %w{.ebnf} do |t| puts "build #{t.name}" File.open(t.name, "w") do |f| - IO.popen(%(bin/ebnf --input-format native #{t.source})).each_line do |line| + IO.popen(%(bin/ebnf #{t.source})).each_line do |line| f.puts ' ' + line end end @@ -89,7 +89,7 @@ end rule ".peg.sxp" => %w{.ebnf} do |t| puts "build #{t.name}" File.open(t.name, "w") do |f| - IO.popen(%(bin/ebnf --input-format native --peg #{t.source})).each_line do |line| + IO.popen(%(bin/ebnf --peg #{t.source})).each_line do |line| f.puts ' ' + line end end @@ -97,13 +97,13 @@ end rule ".html" => %w{.ebnf} do |t| puts "build #{t.name}" - %x(bin/ebnf --input-format native --format html -o #{t.name} #{t.source}) + %x(bin/ebnf --format html -o #{t.name} #{t.source}) end file "etc/ebnf.ll1.sxp" => "etc/ebnf.ebnf" do |t| puts "build #{t.name}" File.open(t.name, "w") do |f| - IO.popen(%(bin/ebnf --input-format native --ll1 ebnf #{t.source})).each_line do |line| + IO.popen(%(bin/ebnf --ll1 ebnf #{t.source})).each_line do |line| f.puts ' ' + line end end @@ -111,10 +111,10 @@ end file "etc/ebnf.peg.rb" => "etc/ebnf.ebnf" do |t| puts "build #{t.name}" - %x(bin/ebnf --input-format native --peg --mod-name EBNFMeta -f rb -o etc/ebnf.peg.rb etc/ebnf.ebnf) + %x(bin/ebnf --peg --mod-name EBNFMeta -f rb -o etc/ebnf.peg.rb etc/ebnf.ebnf) end file "etc/ebnf.ll1.rb" => "etc/ebnf.ebnf" do |t| puts "build #{t.name}" - %x(bin/ebnf --input-format native --ll1 ebnf -f rb -o etc/ebnf.ll1.rb etc/ebnf.ebnf) + %x(bin/ebnf --ll1 ebnf -f rb -o etc/ebnf.ll1.rb etc/ebnf.ebnf) end diff --git a/etc/abnf.sxp b/etc/abnf.sxp index df0b99b..e38ca32 100644 --- a/etc/abnf.sxp +++ b/etc/abnf.sxp @@ -28,7 +28,7 @@ (seq "x" (plus HEXDIG) (opt (alt (plus (seq "." (plus HEXDIG))) (seq "-" (plus HEXDIG)))))) (terminal prose_val (seq "<" (star (range "#x20-#x3D#x3F-#x7E")) ">")) (terminal ALPHA (range "#x41-#x5A#x61-#x7A")) - (terminal BIT (alt "0" "1")) + (terminal BIT (alt '0' '1')) (terminal CHAR (range "#x01-#x7F")) (terminal CR (hex "#x0D")) (terminal CRLF (seq (opt CR) LF)) diff --git a/etc/ebnf.html b/etc/ebnf.html index 0888c91..49fa571 100644 --- a/etc/ebnf.html +++ b/etc/ebnf.html @@ -1,4 +1,4 @@ - +
[2] | declaration |
::= | -"@terminals " | pass |
+ '@terminals ' | pass |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[3] | @@ -29,7 +29,7 @@[5] | alt |
::= | -seq ( "| " seq) * |
+ seq ( '| ' seq) * |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[6] | @@ -41,7 +41,7 @@[7] | diff |
::= | -postfix ( "- " postfix) ? |
+ postfix ( '- ' postfix) ? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[8] | @@ -53,13 +53,13 @@[9] | primary |
::= | -HEX | SYMBOL | O_RANGE | RANGE | STRING1 | STRING2 | ( "( " expression ") ") |
+ HEX | SYMBOL | O_RANGE | RANGE | STRING1 | STRING2 | ( '( ' expression ') ') |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[10] | pass |
::= | -"@pass " expression |
+ '@pass ' expression |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@terminals | @@ -71,31 +71,31 @@[11] | LHS |
::= | -( "[ " SYMBOL "] " #x20 + ) ? SYMBOL #x20 * "::= " |
+ ( '[ ' SYMBOL '] ' #x20 + ) ? SYMBOL #x20 * '::= ' |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[12] | SYMBOL |
::= | -( [ a-z ] | [ A-Z ] | [ 0-9 ] | "_ " | ". ") + |
+ ( [ a-z ] | [ A-Z ] | [ 0-9 ] | '_ ' | '. ') + |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[13] | HEX |
::= | -"#x " ( [ a-f ] | [ A-F ] | [ 0-9 ] ) + |
+ '#x ' ( [ a-f ] | [ A-F ] | [ 0-9 ] ) + |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[14] | RANGE |
::= | -"[ " ( ( R_CHAR "- " R_CHAR) | ( HEX "- " HEX) | R_CHAR | HEX) + "- "? ( "] " - LHS) |
+ '[ ' ( ( R_CHAR '- ' R_CHAR) | ( HEX '- ' HEX) | R_CHAR | HEX) + '- '? ( '] ' - LHS) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[15] | O_RANGE |
::= | -"[^ " ( ( R_CHAR "- " R_CHAR) | ( HEX "- " HEX) | R_CHAR | HEX) + "- "? "] " |
+ '[^ ' ( ( R_CHAR '- ' R_CHAR) | ( HEX '- ' HEX) | R_CHAR | HEX) + '- '? '] ' |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[16] | @@ -119,7 +119,7 @@[19] | R_CHAR |
::= | -CHAR - ( "] " | "- " | HEX) |
+ CHAR - ( '] ' | '- ' | HEX) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[20] | @@ -131,7 +131,7 @@[21] | PASS |
::= | -[ #x09 #x0A #x0D #x20 ] | ( ( ( "# " - "#x ") | "// ") [ ^ #x0A #x0D ] * ) | ( "/* " ( ( "* " [ ^/ ] ) ? | [ ^* ] ) * "*/ ") | ( "(* " ( ( "* " [ ^) ] ) ? | [ ^* ] ) * "*) ") |
+ [ #x09 #x0A #x0D #x20 ] | ( ( ( '# ' - '#x ') | '// ') [ ^ #x0A #x0D ] * ) | ( '/* ' ( ( '* ' [ ^/ ] ) ? | [ ^* ] ) * '*/ ') | ( '(* ' ( ( '* ' [ ^) ] ) ? | [ ^* ] ) * '*) ') |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@pass | diff --git a/etc/ebnf.ll1.rb b/etc/ebnf.ll1.rb index ffde156..2a50869 100644 --- a/etc/ebnf.ll1.rb +++ b/etc/ebnf.ll1.rb @@ -1,4 +1,4 @@ -# This file is automatically generated by ebnf version 2.3.4 +# This file is automatically generated by ebnf version 2.4.0 # Derived from etc/ebnf.ebnf module Meta START = :ebnf diff --git a/etc/ebnf.ll1.sxp b/etc/ebnf.ll1.sxp index 1efb787..c64ce53 100644 --- a/etc/ebnf.ll1.sxp +++ b/etc/ebnf.ll1.sxp @@ -2,114 +2,114 @@ (rule _empty "0" (first _eps) (seq)) (rule ebnf "1" (start #t) - (first "@pass" "@terminals" LHS _eps) + (first '@pass' '@terminals' LHS _eps) (follow _eof) (cleanup star) (alt _empty _ebnf_2)) (rule _ebnf_2 "1.2" - (first "@pass" "@terminals" LHS) + (first '@pass' '@terminals' LHS) (follow _eof) (cleanup merge) (seq _ebnf_1 ebnf)) (rule _ebnf_1 "1.1" - (first "@pass" "@terminals" LHS) - (follow "@pass" "@terminals" LHS _eof) + (first '@pass' '@terminals' LHS) + (follow '@pass' '@terminals' LHS _eof) (alt declaration rule)) (rule declaration "2" - (first "@pass" "@terminals") - (follow "@pass" "@terminals" LHS _eof) - (alt "@terminals" pass)) - (rule rule "3" (first LHS) (follow "@pass" "@terminals" LHS _eof) (seq LHS expression)) + (first '@pass' '@terminals') + (follow '@pass' '@terminals' LHS _eof) + (alt '@terminals' pass)) + (rule rule "3" (first LHS) (follow '@pass' '@terminals' LHS _eof) (seq LHS expression)) (rule expression "4" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow ")" "@pass" "@terminals" LHS _eof) + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow ')' '@pass' '@terminals' LHS _eof) (seq alt)) (rule alt "5" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow ")" "@pass" "@terminals" LHS _eof) + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow ')' '@pass' '@terminals' LHS _eof) (seq seq _alt_1)) (rule _alt_1 "5.1" - (first _eps "|") - (follow ")" "@pass" "@terminals" LHS _eof) + (first _eps '|') + (follow ')' '@pass' '@terminals' LHS _eof) (cleanup star) (alt _empty _alt_3)) (rule _alt_3 "5.3" - (first "|") - (follow ")" "@pass" "@terminals" LHS _eof) + (first '|') + (follow ')' '@pass' '@terminals' LHS _eof) (cleanup merge) (seq _alt_2 _alt_1)) (rule _alt_2 "5.2" - (first "|") - (follow ")" "@pass" "@terminals" LHS _eof "|") - (seq "|" seq)) + (first '|') + (follow ')' '@pass' '@terminals' LHS _eof '|') + (seq '|' seq)) (rule seq "6" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow ")" "@pass" "@terminals" LHS _eof "|") + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow ')' '@pass' '@terminals' LHS _eof '|') (cleanup plus) (seq diff _seq_1)) (rule _seq_1 "6.1" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL _eps) - (follow ")" "@pass" "@terminals" LHS _eof "|") + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL _eps) + (follow ')' '@pass' '@terminals' LHS _eof '|') (cleanup star) (alt _empty _seq_2)) (rule _seq_2 "6.2" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow ")" "@pass" "@terminals" LHS _eof "|") + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow ')' '@pass' '@terminals' LHS _eof '|') (cleanup merge) (seq diff _seq_1)) (rule diff "7" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow "(" ")" "@pass" "@terminals" HEX LHS O_RANGE RANGE STRING1 STRING2 - SYMBOL _eof "|" ) + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow '(' ')' '@pass' '@terminals' HEX LHS O_RANGE RANGE STRING1 STRING2 + SYMBOL _eof '|' ) (seq postfix _diff_1)) (rule _diff_1 "7.1" - (first "-" _eps) - (follow "(" ")" "@pass" "@terminals" HEX LHS O_RANGE RANGE STRING1 STRING2 - SYMBOL _eof "|" ) + (first '-' _eps) + (follow '(' ')' '@pass' '@terminals' HEX LHS O_RANGE RANGE STRING1 STRING2 + SYMBOL _eof '|' ) (cleanup opt) (alt _empty _diff_2)) (rule _diff_2 "7.2" - (first "-") - (follow "(" ")" "@pass" "@terminals" HEX LHS O_RANGE RANGE STRING1 STRING2 - SYMBOL _eof "|" ) - (seq "-" postfix)) + (first '-') + (follow '(' ')' '@pass' '@terminals' HEX LHS O_RANGE RANGE STRING1 STRING2 + SYMBOL _eof '|' ) + (seq '-' postfix)) (rule postfix "8" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow "(" ")" "-" "@pass" "@terminals" HEX LHS O_RANGE RANGE STRING1 - STRING2 SYMBOL _eof "|" ) + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow '(' ')' '-' '@pass' '@terminals' HEX LHS O_RANGE RANGE STRING1 + STRING2 SYMBOL _eof '|' ) (seq primary _postfix_1)) (rule _postfix_1 "8.1" (first POSTFIX _eps) - (follow "(" ")" "-" "@pass" "@terminals" HEX LHS O_RANGE RANGE STRING1 - STRING2 SYMBOL _eof "|" ) + (follow '(' ')' '-' '@pass' '@terminals' HEX LHS O_RANGE RANGE STRING1 + STRING2 SYMBOL _eof '|' ) (cleanup opt) (alt _empty POSTFIX)) (rule primary "9" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow "(" ")" "-" "@pass" "@terminals" HEX LHS O_RANGE POSTFIX RANGE - STRING1 STRING2 SYMBOL _eof "|" ) + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow '(' ')' '-' '@pass' '@terminals' HEX LHS O_RANGE POSTFIX RANGE + STRING1 STRING2 SYMBOL _eof '|' ) (alt HEX SYMBOL O_RANGE RANGE STRING1 STRING2 _primary_1)) (rule _primary_1 "9.1" - (first "(") - (follow "(" ")" "-" "@pass" "@terminals" HEX LHS O_RANGE POSTFIX RANGE - STRING1 STRING2 SYMBOL _eof "|" ) - (seq "(" expression ")")) + (first '(') + (follow '(' ')' '-' '@pass' '@terminals' HEX LHS O_RANGE POSTFIX RANGE + STRING1 STRING2 SYMBOL _eof '|' ) + (seq '(' expression ')')) (rule pass "10" - (first "@pass") - (follow "@pass" "@terminals" LHS _eof) - (seq "@pass" expression)) + (first '@pass') + (follow '@pass' '@terminals' LHS _eof) + (seq '@pass' expression)) (terminals _terminals (seq)) - (terminal LHS "11" (seq (opt (seq "[" SYMBOL "]" (plus " "))) SYMBOL (star " ") "::=")) - (terminal SYMBOL "12" (plus (alt (range "a-z") (range "A-Z") (range "0-9") "_" "."))) - (terminal HEX "13" (seq "#x" (plus (alt (range "a-f") (range "A-F") (range "0-9"))))) + (terminal LHS "11" (seq (opt (seq '[' SYMBOL ']' (plus ' '))) SYMBOL (star ' ') '::=')) + (terminal SYMBOL "12" (plus (alt (range "a-z") (range "A-Z") (range "0-9") '_' '.'))) + (terminal HEX "13" (seq '#x' (plus (alt (range "a-f") (range "A-F") (range "0-9"))))) (terminal RANGE "14" - (seq "[" - (plus (alt (seq R_CHAR "-" R_CHAR) (seq HEX "-" HEX) R_CHAR HEX)) - (opt "-") - (diff "]" LHS)) ) + (seq '[' + (plus (alt (seq R_CHAR '-' R_CHAR) (seq HEX '-' HEX) R_CHAR HEX)) + (opt '-') + (diff ']' LHS)) ) (terminal O_RANGE "15" - (seq "[^" (plus (alt (seq R_CHAR "-" R_CHAR) (seq HEX "-" HEX) R_CHAR HEX)) (opt "-") "]")) - (terminal STRING1 "16" (seq "\"" (star (diff CHAR "\"")) "\"")) + (seq '[^' (plus (alt (seq R_CHAR '-' R_CHAR) (seq HEX '-' HEX) R_CHAR HEX)) (opt '-') ']')) + (terminal STRING1 "16" (seq '"' (star (diff CHAR '"')) '"')) (terminal STRING2 "17" (seq "'" (star (diff CHAR "'")) "'")) (terminal CHAR "18" (alt @@ -117,66 +117,66 @@ (range "#x20-#xD7FF") (range "#xE000-#xFFFD") (range "#x10000-#x10FFFF")) ) - (terminal R_CHAR "19" (diff CHAR (alt "]" "-" HEX))) + (terminal R_CHAR "19" (diff CHAR (alt ']' '-' HEX))) (terminal POSTFIX "20" (range "?*+")) (terminal PASS "21" (alt (range "#x9#xA#xD#x20") - (seq (alt (diff "#" "#x") "//") (star (range "^#xA#xD"))) - (seq "/*" (star (alt (opt (seq "*" (range "^/"))) (range "^*"))) "*/") - (seq "(*" (star (alt (opt (seq "*" (range "^)"))) (range "^*"))) "*)")) ) + (seq (alt (diff '#' '#x') '//') (star (range "^#xA#xD"))) + (seq '/*' (star (alt (opt (seq '*' (range "^/"))) (range "^*"))) '*/') + (seq '(*' (star (alt (opt (seq '*' (range "^)"))) (range "^*"))) '*)')) ) (pass _pass (seq PASS)) - (rule _ebnf_3 "1.3" (first "@pass" "@terminals" LHS _eps) (follow _eof) (seq ebnf)) + (rule _ebnf_3 "1.3" (first '@pass' '@terminals' LHS _eps) (follow _eof) (seq ebnf)) (rule _rule_1 "3.1" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow "@pass" "@terminals" LHS _eof) + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow '@pass' '@terminals' LHS _eof) (seq expression)) (rule _alt_4 "5.4" - (first _eps "|") - (follow ")" "@pass" "@terminals" LHS _eof) + (first _eps '|') + (follow ')' '@pass' '@terminals' LHS _eof) (seq _alt_1)) (rule _alt_5 "5.5" - (first _eps "|") - (follow ")" "@pass" "@terminals" LHS _eof) + (first _eps '|') + (follow ')' '@pass' '@terminals' LHS _eof) (seq _alt_1)) (rule _alt_6 "5.6" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow ")" "@pass" "@terminals" LHS _eof "|") + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow ')' '@pass' '@terminals' LHS _eof '|') (seq seq)) (rule _seq_3 "6.3" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL _eps) - (follow ")" "@pass" "@terminals" LHS _eof "|") + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL _eps) + (follow ')' '@pass' '@terminals' LHS _eof '|') (seq _seq_1)) (rule _seq_4 "6.4" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL _eps) - (follow ")" "@pass" "@terminals" LHS _eof "|") + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL _eps) + (follow ')' '@pass' '@terminals' LHS _eof '|') (seq _seq_1)) (rule _diff_3 "7.3" - (first "-" _eps) - (follow "(" ")" "@pass" "@terminals" HEX LHS O_RANGE RANGE STRING1 STRING2 - SYMBOL _eof "|" ) + (first '-' _eps) + (follow '(' ')' '@pass' '@terminals' HEX LHS O_RANGE RANGE STRING1 STRING2 + SYMBOL _eof '|' ) (seq _diff_1)) (rule _diff_4 "7.4" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow "(" ")" "@pass" "@terminals" HEX LHS O_RANGE RANGE STRING1 STRING2 - SYMBOL _eof "|" ) + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow '(' ')' '@pass' '@terminals' HEX LHS O_RANGE RANGE STRING1 STRING2 + SYMBOL _eof '|' ) (seq postfix)) (rule _postfix_2 "8.2" (first POSTFIX _eps) - (follow "(" ")" "-" "@pass" "@terminals" HEX LHS O_RANGE RANGE STRING1 - STRING2 SYMBOL _eof "|" ) + (follow '(' ')' '-' '@pass' '@terminals' HEX LHS O_RANGE RANGE STRING1 + STRING2 SYMBOL _eof '|' ) (seq _postfix_1)) (rule _primary_2 "9.2" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow "(" ")" "-" "@pass" "@terminals" HEX LHS O_RANGE POSTFIX RANGE - STRING1 STRING2 SYMBOL _eof "|" ) - (seq expression ")")) + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow '(' ')' '-' '@pass' '@terminals' HEX LHS O_RANGE POSTFIX RANGE + STRING1 STRING2 SYMBOL _eof '|' ) + (seq expression ')')) (rule _pass_1 "10.1" - (first "(" HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) - (follow "@pass" "@terminals" LHS _eof) + (first '(' HEX O_RANGE RANGE STRING1 STRING2 SYMBOL) + (follow '@pass' '@terminals' LHS _eof) (seq expression)) (rule _primary_3 "9.3" - (first ")") - (follow "(" ")" "-" "@pass" "@terminals" HEX LHS O_RANGE POSTFIX RANGE - STRING1 STRING2 SYMBOL _eof "|" ) - (seq ")")) ) + (first ')') + (follow '(' ')' '-' '@pass' '@terminals' HEX LHS O_RANGE POSTFIX RANGE + STRING1 STRING2 SYMBOL _eof '|' ) + (seq ')')) ) diff --git a/etc/ebnf.peg.rb b/etc/ebnf.peg.rb index a0f4e73..070430d 100644 --- a/etc/ebnf.peg.rb +++ b/etc/ebnf.peg.rb @@ -1,4 +1,4 @@ -# This file is automatically generated by ebnf version 2.3.4 +# This file is automatically generated by ebnf version 2.4.0 # Derived from etc/ebnf.ebnf module EBNFMeta RULES = [ diff --git a/etc/ebnf.peg.sxp b/etc/ebnf.peg.sxp index b30b54b..78bd279 100644 --- a/etc/ebnf.peg.sxp +++ b/etc/ebnf.peg.sxp @@ -1,54 +1,54 @@ ( (rule ebnf "1" (star _ebnf_1)) (rule _ebnf_1 "1.1" (alt declaration rule)) - (rule declaration "2" (alt "@terminals" pass)) + (rule declaration "2" (alt '@terminals' pass)) (rule rule "3" (seq LHS expression)) (rule expression "4" (seq alt)) (rule alt "5" (seq seq _alt_1)) (rule _alt_1 "5.1" (star _alt_2)) - (rule _alt_2 "5.2" (seq "|" seq)) + (rule _alt_2 "5.2" (seq '|' seq)) (rule seq "6" (plus diff)) (rule diff "7" (seq postfix _diff_1)) (rule _diff_1 "7.1" (opt _diff_2)) - (rule _diff_2 "7.2" (seq "-" postfix)) + (rule _diff_2 "7.2" (seq '-' postfix)) (rule postfix "8" (seq primary _postfix_1)) (rule _postfix_1 "8.1" (opt POSTFIX)) (rule primary "9" (alt HEX SYMBOL O_RANGE RANGE STRING1 STRING2 _primary_1)) - (rule _primary_1 "9.1" (seq "(" expression ")")) - (rule pass "10" (seq "@pass" expression)) + (rule _primary_1 "9.1" (seq '(' expression ')')) + (rule pass "10" (seq '@pass' expression)) (terminals _terminals (seq)) - (terminal LHS "11" (seq _LHS_1 SYMBOL _LHS_2 "::=")) + (terminal LHS "11" (seq _LHS_1 SYMBOL _LHS_2 '::=')) (terminal _LHS_1 "11.1" (opt _LHS_3)) - (terminal _LHS_3 "11.3" (seq "[" SYMBOL "]" _LHS_4)) - (terminal _LHS_4 "11.4" (plus " ")) - (terminal _LHS_2 "11.2" (star " ")) + (terminal _LHS_3 "11.3" (seq '[' SYMBOL ']' _LHS_4)) + (terminal _LHS_4 "11.4" (plus ' ')) + (terminal _LHS_2 "11.2" (star ' ')) (terminal SYMBOL "12" (plus _SYMBOL_1)) - (terminal _SYMBOL_1 "12.1" (alt _SYMBOL_2 _SYMBOL_3 _SYMBOL_4 "_" ".")) + (terminal _SYMBOL_1 "12.1" (alt _SYMBOL_2 _SYMBOL_3 _SYMBOL_4 '_' '.')) (terminal _SYMBOL_2 "12.2" (range "a-z")) (terminal _SYMBOL_3 "12.3" (range "A-Z")) (terminal _SYMBOL_4 "12.4" (range "0-9")) - (terminal HEX "13" (seq "#x" _HEX_1)) + (terminal HEX "13" (seq '#x' _HEX_1)) (terminal _HEX_1 "13.1" (plus _HEX_2)) (terminal _HEX_2 "13.2" (alt _HEX_3 _HEX_4 _HEX_5)) (terminal _HEX_3 "13.3" (range "a-f")) (terminal _HEX_4 "13.4" (range "A-F")) (terminal _HEX_5 "13.5" (range "0-9")) - (terminal RANGE "14" (seq "[" _RANGE_1 _RANGE_2 _RANGE_3)) + (terminal RANGE "14" (seq '[' _RANGE_1 _RANGE_2 _RANGE_3)) (terminal _RANGE_1 "14.1" (plus _RANGE_4)) (terminal _RANGE_4 "14.4" (alt _RANGE_5 _RANGE_6 R_CHAR HEX)) - (terminal _RANGE_5 "14.5" (seq R_CHAR "-" R_CHAR)) - (terminal _RANGE_6 "14.6" (seq HEX "-" HEX)) - (terminal _RANGE_2 "14.2" (opt "-")) - (terminal _RANGE_3 "14.3" (diff "]" LHS)) - (terminal O_RANGE "15" (seq "[^" _O_RANGE_1 _O_RANGE_2 "]")) + (terminal _RANGE_5 "14.5" (seq R_CHAR '-' R_CHAR)) + (terminal _RANGE_6 "14.6" (seq HEX '-' HEX)) + (terminal _RANGE_2 "14.2" (opt '-')) + (terminal _RANGE_3 "14.3" (diff ']' LHS)) + (terminal O_RANGE "15" (seq '[^' _O_RANGE_1 _O_RANGE_2 ']')) (terminal _O_RANGE_1 "15.1" (plus _O_RANGE_3)) (terminal _O_RANGE_3 "15.3" (alt _O_RANGE_4 _O_RANGE_5 R_CHAR HEX)) - (terminal _O_RANGE_4 "15.4" (seq R_CHAR "-" R_CHAR)) - (terminal _O_RANGE_5 "15.5" (seq HEX "-" HEX)) - (terminal _O_RANGE_2 "15.2" (opt "-")) - (terminal STRING1 "16" (seq "\"" _STRING1_1 "\"")) + (terminal _O_RANGE_4 "15.4" (seq R_CHAR '-' R_CHAR)) + (terminal _O_RANGE_5 "15.5" (seq HEX '-' HEX)) + (terminal _O_RANGE_2 "15.2" (opt '-')) + (terminal STRING1 "16" (seq '"' _STRING1_1 '"')) (terminal _STRING1_1 "16.1" (star _STRING1_2)) - (terminal _STRING1_2 "16.2" (diff CHAR "\"")) + (terminal _STRING1_2 "16.2" (diff CHAR '"')) (terminal STRING2 "17" (seq "'" _STRING2_1 "'")) (terminal _STRING2_1 "17.1" (star _STRING2_2)) (terminal _STRING2_2 "17.2" (diff CHAR "'")) @@ -58,27 +58,27 @@ (terminal _CHAR_3 "18.3" (range "#xE000-#xFFFD")) (terminal _CHAR_4 "18.4" (range "#x10000-#x10FFFF")) (terminal R_CHAR "19" (diff CHAR _R_CHAR_1)) - (terminal _R_CHAR_1 "19.1" (alt "]" "-" HEX)) + (terminal _R_CHAR_1 "19.1" (alt ']' '-' HEX)) (terminal POSTFIX "20" (range "?*+")) (terminal PASS "21" (alt _PASS_1 _PASS_2 _PASS_3 _PASS_4)) (terminal _PASS_1 "21.1" (range "#x9#xA#xD#x20")) (terminal _PASS_2 "21.2" (seq _PASS_5 _PASS_6)) - (terminal _PASS_5 "21.5" (alt _PASS_7 "//")) - (terminal _PASS_7 "21.7" (diff "#" "#x")) + (terminal _PASS_5 "21.5" (alt _PASS_7 '//')) + (terminal _PASS_7 "21.7" (diff '#' '#x')) (terminal _PASS_6 "21.6" (star _PASS_8)) (terminal _PASS_8 "21.8" (range "^#xA#xD")) - (terminal _PASS_3 "21.3" (seq "/*" _PASS_9 "*/")) + (terminal _PASS_3 "21.3" (seq '/*' _PASS_9 '*/')) (terminal _PASS_9 "21.9" (star _PASS_10)) (terminal _PASS_10 "21.10" (alt _PASS_11 _PASS_12)) (terminal _PASS_11 "21.11" (opt _PASS_13)) - (terminal _PASS_13 "21.13" (seq "*" _PASS_14)) + (terminal _PASS_13 "21.13" (seq '*' _PASS_14)) (terminal _PASS_14 "21.14" (range "^/")) (terminal _PASS_12 "21.12" (range "^*")) - (terminal _PASS_4 "21.4" (seq "(*" _PASS_15 "*)")) + (terminal _PASS_4 "21.4" (seq '(*' _PASS_15 '*)')) (terminal _PASS_15 "21.15" (star _PASS_16)) (terminal _PASS_16 "21.16" (alt _PASS_17 _PASS_18)) (terminal _PASS_17 "21.17" (opt _PASS_19)) - (terminal _PASS_19 "21.19" (seq "*" _PASS_20)) + (terminal _PASS_19 "21.19" (seq '*' _PASS_20)) (terminal _PASS_20 "21.20" (range "^)")) (terminal _PASS_18 "21.18" (range "^*")) (pass _pass (seq PASS))) diff --git a/etc/ebnf.sxp b/etc/ebnf.sxp index 1fded9e..028b01f 100644 --- a/etc/ebnf.sxp +++ b/etc/ebnf.sxp @@ -1,27 +1,27 @@ ( (rule ebnf "1" (star (alt declaration rule))) - (rule declaration "2" (alt "@terminals" pass)) + (rule declaration "2" (alt '@terminals' pass)) (rule rule "3" (seq LHS expression)) (rule expression "4" (seq alt)) - (rule alt "5" (seq seq (star (seq "|" seq)))) + (rule alt "5" (seq seq (star (seq '|' seq)))) (rule seq "6" (plus diff)) - (rule diff "7" (seq postfix (opt (seq "-" postfix)))) + (rule diff "7" (seq postfix (opt (seq '-' postfix)))) (rule postfix "8" (seq primary (opt POSTFIX))) (rule primary "9" - (alt HEX SYMBOL O_RANGE RANGE STRING1 STRING2 (seq "(" expression ")"))) - (rule pass "10" (seq "@pass" expression)) + (alt HEX SYMBOL O_RANGE RANGE STRING1 STRING2 (seq '(' expression ')'))) + (rule pass "10" (seq '@pass' expression)) (terminals _terminals (seq)) - (terminal LHS "11" (seq (opt (seq "[" SYMBOL "]" (plus " "))) SYMBOL (star " ") "::=")) - (terminal SYMBOL "12" (plus (alt (range "a-z") (range "A-Z") (range "0-9") "_" "."))) - (terminal HEX "13" (seq "#x" (plus (alt (range "a-f") (range "A-F") (range "0-9"))))) + (terminal LHS "11" (seq (opt (seq '[' SYMBOL ']' (plus ' '))) SYMBOL (star ' ') '::=')) + (terminal SYMBOL "12" (plus (alt (range "a-z") (range "A-Z") (range "0-9") '_' '.'))) + (terminal HEX "13" (seq '#x' (plus (alt (range "a-f") (range "A-F") (range "0-9"))))) (terminal RANGE "14" - (seq "[" - (plus (alt (seq R_CHAR "-" R_CHAR) (seq HEX "-" HEX) R_CHAR HEX)) - (opt "-") - (diff "]" LHS)) ) + (seq '[' + (plus (alt (seq R_CHAR '-' R_CHAR) (seq HEX '-' HEX) R_CHAR HEX)) + (opt '-') + (diff ']' LHS)) ) (terminal O_RANGE "15" - (seq "[^" (plus (alt (seq R_CHAR "-" R_CHAR) (seq HEX "-" HEX) R_CHAR HEX)) (opt "-") "]")) - (terminal STRING1 "16" (seq "\"" (star (diff CHAR "\"")) "\"")) + (seq '[^' (plus (alt (seq R_CHAR '-' R_CHAR) (seq HEX '-' HEX) R_CHAR HEX)) (opt '-') ']')) + (terminal STRING1 "16" (seq '"' (star (diff CHAR '"')) '"')) (terminal STRING2 "17" (seq "'" (star (diff CHAR "'")) "'")) (terminal CHAR "18" (alt @@ -29,12 +29,12 @@ (range "#x20-#xD7FF") (range "#xE000-#xFFFD") (range "#x10000-#x10FFFF")) ) - (terminal R_CHAR "19" (diff CHAR (alt "]" "-" HEX))) + (terminal R_CHAR "19" (diff CHAR (alt ']' '-' HEX))) (terminal POSTFIX "20" (range "?*+")) (terminal PASS "21" (alt (range "#x9#xA#xD#x20") - (seq (alt (diff "#" "#x") "//") (star (range "^#xA#xD"))) - (seq "/*" (star (alt (opt (seq "*" (range "^/"))) (range "^*"))) "*/") - (seq "(*" (star (alt (opt (seq "*" (range "^)"))) (range "^*"))) "*)")) ) + (seq (alt (diff '#' '#x') '//') (star (range "^#xA#xD"))) + (seq '/*' (star (alt (opt (seq '*' (range "^/"))) (range "^*"))) '*/') + (seq '(*' (star (alt (opt (seq '*' (range "^)"))) (range "^*"))) '*)')) ) (pass _pass (seq PASS))) diff --git a/etc/iso-ebnf.sxp b/etc/iso-ebnf.sxp index 099e7c4..db2cdb7 100644 --- a/etc/iso-ebnf.sxp +++ b/etc/iso-ebnf.sxp @@ -4,10 +4,10 @@ (seq meta_identifier defining_symbol definitions_list terminator_symbol)) (rule definitions_list (seq single_definition (star (seq definition_separator_symbol definitions_list)))) - (rule single_definition (seq term (star (seq "," term)))) - (rule term (seq factor (opt (seq "-" exception)))) + (rule single_definition (seq term (star (seq ',' term)))) + (rule term (seq factor (opt (seq '-' exception)))) (rule exception (seq factor)) - (rule factor (seq (opt (seq integer "*")) primary)) + (rule factor (seq (opt (seq integer '*')) primary)) (rule primary (alt optional_sequence repeated_sequence special_sequence grouped_sequence meta_identifier terminal_string empty )) @@ -15,25 +15,25 @@ (seq start_option_symbol definitions_list end_option_symbol)) (rule repeated_sequence (seq start_repeat_symbol definitions_list end_repeat_symbol)) - (rule grouped_sequence (seq "(" definitions_list ")")) + (rule grouped_sequence (seq '(' definitions_list ')')) (terminals _terminals (seq)) (terminal terminal_string (alt (seq "'" (plus first_terminal_character) "'") - (seq "\"" (plus second_terminal_character) "\"")) ) + (seq '"' (plus second_terminal_character) '"')) ) (terminal meta_identifier (seq letter (star meta_identifier_character))) (terminal integer (plus decimal_digit)) - (terminal special_sequence (seq "?" (star special_sequence_character) "?")) + (terminal special_sequence (seq '?' (star special_sequence_character) '?')) (terminal comment (seq start_comment_symbol (star comment_symbol) end_comment_symbol)) (terminal comment_symbol (alt comment commentless_symbol other_character)) (terminal commentless_symbol (alt terminal_character meta_identifier integer terminal_string special_sequence)) (terminal letter (range "a-zA-Z")) (terminal decimal_digit (range "0-9")) - (terminal meta_identifier_character (alt letter decimal_digit "_")) + (terminal meta_identifier_character (alt letter decimal_digit '_')) (terminal first_terminal_character (diff terminal_character "'")) - (terminal second_terminal_character (diff terminal_character "\"")) - (terminal special_sequence_character (diff terminal_character "?")) + (terminal second_terminal_character (diff terminal_character '"')) + (terminal special_sequence_character (diff terminal_character '?')) (terminal terminal_character (alt letter decimal_digit concatenate_symbol defining_symbol definition_separator_symbol end_comment_symbol end_group_symbol @@ -41,25 +41,25 @@ repetition_symbol second_quote_symbol special_sequence_symbol start_comment_symbol start_group_symbol start_option_symbol start_repeat_symbol terminator_symbol other_character )) - (terminal other_character (alt (range ":+_%@&$<>^` ̃#x20#x23") "\\")) + (terminal other_character (alt (range ":+_%@&$<>^` ̃#x20#x23") '\\')) (terminal gap_separator (range "#x9#xa#xb#xc#xd#x20")) (pass _pass (alt (plus gap_separator) comment)) - (terminal empty (seq "")) - (terminal concatenate_symbol (seq ",")) - (terminal repetition_symbol (seq "*")) - (terminal except_symbol (seq "-")) + (terminal empty (seq '')) + (terminal concatenate_symbol (seq ',')) + (terminal repetition_symbol (seq '*')) + (terminal except_symbol (seq '-')) (terminal first_quote_symbol (seq "'")) - (terminal second_quote_symbol (seq "\"")) - (terminal start_comment_symbol (seq "(*")) - (terminal end_comment_symbol (seq "*)")) - (terminal start_group_symbol (seq "(")) - (terminal end_group_symbol (seq ")")) - (terminal special_sequence_symbol (seq "?")) - (terminal defining_symbol (alt "=" ":")) - (terminal definition_separator_symbol (alt "|" "/" "!")) - (terminal terminator_symbol (alt ";" ".")) - (terminal start_option_symbol (seq "[")) - (terminal end_option_symbol (seq "]")) - (terminal start_repeat_symbol (alt "{" "(:")) - (terminal end_repeat_symbol (alt "}" ":)")) + (terminal second_quote_symbol (seq '"')) + (terminal start_comment_symbol (seq '(*')) + (terminal end_comment_symbol (seq '*)')) + (terminal start_group_symbol (seq '(')) + (terminal end_group_symbol (seq ')')) + (terminal special_sequence_symbol (seq '?')) + (terminal defining_symbol (alt '=' ':')) + (terminal definition_separator_symbol (alt '|' '/' '!')) + (terminal terminator_symbol (alt ';' '.')) + (terminal start_option_symbol (seq '[')) + (terminal end_option_symbol (seq ']')) + (terminal start_repeat_symbol (alt '{' '(:')) + (terminal end_repeat_symbol (alt '}' ':)')) (terminal gap_free_symbol (alt (diff terminal_character (range "'\"")) terminal_string))) diff --git a/etc/sparql.html b/etc/sparql.html deleted file mode 100644 index bae9802..0000000 --- a/etc/sparql.html +++ /dev/null @@ -1,1425 +0,0 @@ - -
[1] | -QueryUnit |
- ::= | -Query? |
-
[2] | -Query |
- ::= | -Prologue ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery) |
-
[3] | -UpdateUnit |
- ::= | -Update | -
[4] | -Prologue |
- ::= | -( BaseDecl | PrefixDecl) * |
-
[5] | -BaseDecl |
- ::= | -"BASE " IRIREF |
-
[6] | -PrefixDecl |
- ::= | -"PREFIX " PNAME_NS IRIREF |
-
[7] | -SelectQuery |
- ::= | -SelectClause DatasetClause* WhereClause SolutionModifier ValuesClause |
-
[8] | -SubSelect |
- ::= | -SelectClause WhereClause SolutionModifier ValuesClause | -
[9] | -SelectClause |
- ::= | -"SELECT " ( "DISTINCT " | "REDUCED ") ? ( ( Var | ( "( " Expression "AS " Var ") ") ) + | "* ") |
-
[10] | -ConstructQuery |
- ::= | -"CONSTRUCT " ( ( ConstructTemplate DatasetClause* WhereClause SolutionModifier) | ( DatasetClause* "WHERE " "{ " TriplesTemplate? "} " SolutionModifier) ) ValuesClause |
-
[11] | -DescribeQuery |
- ::= | -"DESCRIBE " ( VarOrIri+ | "* ") DatasetClause* WhereClause? SolutionModifier ValuesClause |
-
[12] | -AskQuery |
- ::= | -"ASK " DatasetClause* WhereClause ValuesClause |
-
[13] | -DatasetClause |
- ::= | -"FROM " ( DefaultGraphClause | NamedGraphClause) |
-
[14] | -DefaultGraphClause |
- ::= | -SourceSelector | -
[15] | -NamedGraphClause |
- ::= | -"NAMED " SourceSelector |
-
[16] | -SourceSelector |
- ::= | -iri | -
[17] | -WhereClause |
- ::= | -"WHERE "? GroupGraphPattern |
-
[18] | -SolutionModifier |
- ::= | -GroupClause? HavingClause? OrderClause? LimitOffsetClauses? |
-
[19] | -GroupClause |
- ::= | -"GROUP " "BY " GroupCondition+ |
-
[20] | -GroupCondition |
- ::= | -BuiltInCall | FunctionCall | ( "( " Expression ( "AS " Var) ? ") ") | Var |
-
[21] | -HavingClause |
- ::= | -"HAVING " HavingCondition+ |
-
[22] | -HavingCondition |
- ::= | -Constraint | -
[23] | -OrderClause |
- ::= | -"ORDER " "BY " OrderCondition+ |
-
[24] | -OrderCondition |
- ::= | -( ( "ASC " | "DESC ") BrackettedExpression) | ( Constraint | Var) |
-
[25] | -LimitOffsetClauses |
- ::= | -( LimitClause OffsetClause? ) | ( OffsetClause LimitClause? ) |
-
[26] | -LimitClause |
- ::= | -"LIMIT " INTEGER |
-
[27] | -OffsetClause |
- ::= | -"OFFSET " INTEGER |
-
[28] | -ValuesClause |
- ::= | -( "VALUES " DataBlock) ? |
-
[29] | -Update |
- ::= | -Prologue ( Update1 ( "; " Update) ? ) ? |
-
[30] | -Update1 |
- ::= | -Load | Clear | Drop | Add | Move | Copy | Create | InsertData | DeleteData | DeleteWhere | Modify |
-
[31] | -Load |
- ::= | -"LOAD " "SILENT "? iri ( "INTO " GraphRef) ? |
-
[32] | -Clear |
- ::= | -"CLEAR " "SILENT "? GraphRefAll |
-
[33] | -Drop |
- ::= | -"DROP " "SILENT "? GraphRefAll |
-
[34] | -Create |
- ::= | -"CREATE " "SILENT "? GraphRef |
-
[35] | -Add |
- ::= | -"ADD " "SILENT "? GraphOrDefault "TO " GraphOrDefault |
-
[36] | -Move |
- ::= | -"MOVE " "SILENT "? GraphOrDefault "TO " GraphOrDefault |
-
[37] | -Copy |
- ::= | -"COPY " "SILENT "? GraphOrDefault "TO " GraphOrDefault |
-
[38] | -InsertData |
- ::= | -"INSERT DATA " QuadData |
-
[39] | -DeleteData |
- ::= | -"DELETE DATA " QuadData |
-
[40] | -DeleteWhere |
- ::= | -"DELETE WHERE " QuadPattern |
-
[41] | -Modify |
- ::= | -( "WITH " iri) ? ( ( DeleteClause InsertClause? ) | InsertClause) UsingClause* "WHERE " GroupGraphPattern |
-
[42] | -DeleteClause |
- ::= | -"DELETE " QuadPattern |
-
[43] | -InsertClause |
- ::= | -"INSERT " QuadPattern |
-
[44] | -UsingClause |
- ::= | -"USING " ( iri | ( "NAMED " iri) ) |
-
[45] | -GraphOrDefault |
- ::= | -"DEFAULT " | ( "GRAPH "? iri) |
-
[46] | -GraphRef |
- ::= | -"GRAPH " iri |
-
[47] | -GraphRefAll |
- ::= | -GraphRef | "DEFAULT " | "NAMED " | "ALL " |
-
[48] | -QuadPattern |
- ::= | -"{ " Quads "} " |
-
[49] | -QuadData |
- ::= | -"{ " Quads "} " |
-
[50] | -Quads |
- ::= | -TriplesTemplate? ( QuadsNotTriples ". "? TriplesTemplate? ) * |
-
[51] | -QuadsNotTriples |
- ::= | -"GRAPH " VarOrIri "{ " TriplesTemplate? "} " |
-
[52] | -TriplesTemplate |
- ::= | -TriplesSameSubject ( ". " TriplesTemplate? ) ? |
-
[53] | -GroupGraphPattern |
- ::= | -"{ " ( SubSelect | GroupGraphPatternSub) "} " |
-
[54] | -GroupGraphPatternSub |
- ::= | -TriplesBlock? ( GraphPatternNotTriples ". "? TriplesBlock? ) * |
-
[55] | -TriplesBlock |
- ::= | -TriplesSameSubjectPath ( ". " TriplesBlock? ) ? |
-
[56] | -GraphPatternNotTriples |
- ::= | -GroupOrUnionGraphPattern | OptionalGraphPattern | MinusGraphPattern | GraphGraphPattern | ServiceGraphPattern | Filter | Bind | InlineData |
-
[57] | -OptionalGraphPattern |
- ::= | -"OPTIONAL " GroupGraphPattern |
-
[58] | -GraphGraphPattern |
- ::= | -"GRAPH " VarOrIri GroupGraphPattern |
-
[59] | -ServiceGraphPattern |
- ::= | -"SERVICE " "SILENT "? VarOrIri GroupGraphPattern |
-
[60] | -Bind |
- ::= | -"BIND " "( " Expression "AS " Var ") " |
-
[61] | -InlineData |
- ::= | -"VALUES " DataBlock |
-
[62] | -DataBlock |
- ::= | -InlineDataOneVar | InlineDataFull |
-
[63] | -InlineDataOneVar |
- ::= | -Var "{ " DataBlockValue* "} " |
-
[64] | -InlineDataFull |
- ::= | -( NIL | ( "( " Var* ") ") ) "{ " ( ( "( " DataBlockValue* ") ") | NIL) * "} " |
-
[65] | -DataBlockValue |
- ::= | -iri | RDFLiteral | NumericLiteral | BooleanLiteral | "UNDEF " |
-
[66] | -MinusGraphPattern |
- ::= | -"MINUS " GroupGraphPattern |
-
[67] | -GroupOrUnionGraphPattern |
- ::= | -GroupGraphPattern ( "UNION " GroupGraphPattern) * |
-
[68] | -Filter |
- ::= | -"FILTER " Constraint |
-
[69] | -Constraint |
- ::= | -BrackettedExpression | BuiltInCall | FunctionCall |
-
[70] | -FunctionCall |
- ::= | -iri ArgList | -
[71] | -ArgList |
- ::= | -NIL | ( "( " "DISTINCT "? Expression ( ", " Expression) * ") ") |
-
[72] | -ExpressionList |
- ::= | -NIL | ( "( " Expression ( ", " Expression) * ") ") |
-
[73] | -ConstructTemplate |
- ::= | -"{ " ConstructTriples? "} " |
-
[74] | -ConstructTriples |
- ::= | -TriplesSameSubject ( ". " ConstructTriples? ) ? |
-
[75] | -TriplesSameSubject |
- ::= | -( VarOrTerm PropertyListNotEmpty) | ( TriplesNode PropertyList) |
-
[76] | -PropertyList |
- ::= | -PropertyListNotEmpty? |
-
[77] | -PropertyListNotEmpty |
- ::= | -Verb ObjectList ( "; " ( Verb ObjectList) ? ) * |
-
[78] | -Verb |
- ::= | -VarOrIri | "a " |
-
[79] | -ObjectList |
- ::= | -Object ( ", " Object) * |
-
[80] | -Object |
- ::= | -GraphNode | -
[81] | -TriplesSameSubjectPath |
- ::= | -( VarOrTerm PropertyListNotEmptyPath) | ( TriplesNode PropertyListPath) |
-
[82] | -PropertyListPath |
- ::= | -PropertyListNotEmpty? |
-
[83] | -PropertyListNotEmptyPath |
- ::= | -( VerbPath | VerbSimple) ObjectList ( "; " ( ( VerbPath | VerbSimple) ObjectList) ? ) * |
-
[84] | -VerbPath |
- ::= | -Path | -
[85] | -VerbSimple |
- ::= | -Var | -
[86] | -ObjectListPath |
- ::= | -ObjectPath ( ", " ObjectPath) * |
-
[87] | -ObjectPath |
- ::= | -GraphNodePath | -
[88] | -Path |
- ::= | -PathAlternative | -
[89] | -PathAlternative |
- ::= | -PathSequence ( "| " PathSequence) * |
-
[90] | -PathSequence |
- ::= | -PathEltOrInverse ( "/ " PathEltOrInverse) * |
-
[91] | -PathElt |
- ::= | -PathPrimary PathMod? |
-
[92] | -PathEltOrInverse |
- ::= | -PathElt | ( "^ " PathElt) |
-
[93] | -PathMod |
- ::= | -"* " | "? " | "+ " | ( "{ " ( ( Integer ( ( ", " ( "} " | ( Integer "} ") ) ) | "} ") ) | ( ", " Integer "} ") ) ) |
-
[94] | -PathPrimary |
- ::= | -iri | "a " | ( "! " PathNegatedPropertySet) | ( "( " Path ") ") |
-
[95] | -PathNegatedPropertySet |
- ::= | -PathOneInPropertySet | ( "( " ( PathOneInPropertySet ( "| " PathOneInPropertySet) * ) ? ") ") |
-
[96] | -PathOneInPropertySet |
- ::= | -iri | "a " | ( "^ " ( iri | "a ") ) |
-
[97] | -Integer |
- ::= | -INTEGER | -
[98] | -TriplesNode |
- ::= | -Collection | BlankNodePropertyList |
-
[99] | -BlankNodePropertyList |
- ::= | -"[ " PropertyListNotEmpty "] " |
-
[100] | -TriplesNodePath |
- ::= | -CollectionPath | BlankNodePropertyListPath |
-
[101] | -BlankNodePropertyListPath |
- ::= | -"[ " PropertyListPathNotEmpty "] " |
-
[102] | -Collection |
- ::= | -"( " GraphNode+ ") " |
-
[103] | -CollectionPath |
- ::= | -"( " GraphNodePath+ ") " |
-
[104] | -GraphNode |
- ::= | -VarOrTerm | TriplesNode |
-
[105] | -GraphNodePath |
- ::= | -VarOrTerm | TriplesNodePath |
-
[106] | -VarOrTerm |
- ::= | -Var | GraphTerm |
-
[107] | -VarOrIri |
- ::= | -Var | iri |
-
[108] | -Var |
- ::= | -VAR1 | VAR2 |
-
[109] | -GraphTerm |
- ::= | -iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL |
-
[110] | -Expression |
- ::= | -ConditionalOrExpression | -
[111] | -ConditionalOrExpression |
- ::= | -ConditionalAndExpression ( "|| " ConditionalAndExpression) * |
-
[112] | -ConditionalAndExpression |
- ::= | -ValueLogical ( "&& " ValueLogical) * |
-
[113] | -ValueLogical |
- ::= | -RelationalExpression | -
[114] | -RelationalExpression |
- ::= | -NumericExpression | -
- | - | ( ( "= " NumericExpression) ( "!= " NumericExpression) | ( "< " NumericExpression) | ( "> " NumericExpression) | ( "<= " NumericExpression) | ( ">= " NumericExpression) | ( "IN " ExpressionList) | ( "NOT " "IN " ExpressionList) ) ? |
- |
[115] | -NumericExpression |
- ::= | -AdditiveExpression | -
[116] | -AdditiveExpression |
- ::= | -MultiplicativeExpression | -
- | - | ( ( "+ " MultiplicativeExpression) ( "- " MultiplicativeExpression) | ( ( NumericLiteralPositive | NumericLiteralNegative) ( ( "* " UnaryExpression) | ( "/ " UnaryExpression) ) ? ) ) * |
- |
[117] | -MultiplicativeExpression |
- ::= | -UnaryExpression ( ( "* " UnaryExpression) | ( "/ " UnaryExpression) ) * |
-
[118] | -UnaryExpression |
- ::= | -( "! " PrimaryExpression) | ( "+ " PrimaryExpression) | ( "- " PrimaryExpression) | PrimaryExpression |
-
[119] | -PrimaryExpression |
- ::= | -BrackettedExpression | BuiltInCall | iriOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var |
-
[120] | -BrackettedExpression |
- ::= | -"( " Expression ") " |
-
[121] | -BuiltInCall |
- ::= | -Aggregate | -
- | | |
- ( "STR " "( " Expression ") ") |
- |
- | | |
- ( "LANG " "( " Expression ") ") |
- |
- | | |
- ( "LANGMATCHES " "( " Expression ", " Expression ") ") |
- |
- | | |
- ( "DATATYPE " "( " Expression ") ") |
- |
- | | |
- ( "BOUND " "( " Var ") ") |
- |
- | | |
- ( "IRI " "( " Expression ") ") |
- |
- | | |
- ( "URI " "( " Expression ") ") |
- |
- | | |
- ( "BNODE " ( ( "( " Expression ") ") | NIL) ) |
- |
- | | |
- ( "RAND " NIL) |
- |
- | | |
- ( "ABS " "( " Expression ") ") |
- |
- | | |
- ( "CEIL " "( " Expression ") ") |
- |
- | | |
- ( "FLOOR " "( " Expression ") ") |
- |
- | | |
- ( "ROUND " "( " Expression ") ") |
- |
- | | |
- ( "CONCAT " ExpressionList) |
- |
- | | |
- SubstringExpression | -|
- | | |
- ( "STRLEN " "( " Expression ") ") |
- |
- | | |
- StrReplaceExpression | -|
- | | |
- ( "UCASE " "( " Expression ") ") |
- |
- | | |
- ( "LCASE " "( " Expression ") ") |
- |
- | | |
- ( "ENCODE_FOR_URI " "( " Expression ") ") |
- |
- | | |
- ( "CONTAINS " "( " Expression ", " Expression ") ") |
- |
- | | |
- ( "STRSTARTS " "( " Expression ", " Expression ") ") |
- |
- | | |
- ( "STRENDS " "( " Expression ", " Expression ") ") |
- |
- | | |
- ( "STRBEFORE " "( " Expression ", " Expression ") ") |
- |
- | | |
- ( "STRAFTER " "( " Expression ", " Expression ") ") |
- |
- | | |
- ( "YEAR " "( " Expression ") ") |
- |
- | | |
- ( "MONTH " "( " Expression ") ") |
- |
- | | |
- ( "DAY " "( " Expression ") ") |
- |
- | | |
- ( "HOURS " "( " Expression ") ") |
- |
- | | |
- ( "MINUTES " "( " Expression ") ") |
- |
- | | |
- ( "SECONDS " "( " Expression ") ") |
- |
- | | |
- ( "TIMEZONE " "( " Expression ") ") |
- |
- | | |
- ( "TZ " "( " Expression ") ") |
- |
- | | |
- ( "NOW " NIL) |
- |
- | | |
- ( "UUID " NIL) |
- |
- | | |
- ( "STRUUID " NIL) |
- |
- | | |
- ( "MD5 " "( " Expression ") ") |
- |
- | | |
- ( "SHA1 " "( " Expression ") ") |
- |
- | | |
- ( "SHA224 " "( " Expression ") ") |
- |
- | | |
- ( "SHA256 " "( " Expression ") ") |
- |
- | | |
- ( "SHA384 " "( " Expression ") ") |
- |
- | | |
- ( "SHA512 " "( " Expression ") ") |
- |
- | | |
- ( "COALESCE " ExpressionList) |
- |
- | | |
- ( "IF " "( " Expression ", " Expression ", " Expression ") ") |
- |
- | | |
- ( "STRLANG " "( " Expression ", " Expression ") ") |
- |
- | | |
- ( "STRDT " "( " Expression ", " Expression ") ") |
- |
- | | |
- ( "sameTerm " "( " Expression ", " Expression ") ") |
- |
- | | |
- ( "isIRI " "( " Expression ") ") |
- |
- | | |
- ( "isURI " "( " Expression ") ") |
- |
- | | |
- ( "isBLANK " "( " Expression ") ") |
- |
- | | |
- ( "isLITERAL " "( " Expression ") ") |
- |
- | | |
- ( "isNUMERIC " "( " Expression ") ") |
- |
- | | |
- RegexExpression | -|
- | | |
- ExistsFunc | -|
- | | |
- NotExistsFunc | -|
[122] | -RegexExpression |
- ::= | -"REGEX " "( " Expression ", " Expression ( ", " Expression) ? ") " |
-
[123] | -SubstringExpression |
- ::= | -"SUBSTR " "( " Expression ", " Expression ( ", " Expression) ? ") " |
-
[124] | -StrReplaceExpression |
- ::= | -"REPLACE " "( " Expression ", " Expression ", " Expression ( ", " Expression) ? ") " |
-
[125] | -ExistsFunc |
- ::= | -"EXISTS " GroupGraphPattern |
-
[126] | -NotExistsFunc |
- ::= | -"NOT " "EXISTS " GroupGraphPattern |
-
[127] | -Aggregate |
- ::= | -( "COUNT " "( " "DISTINCT "? ( "* "Expression) ") ") |
-
- | | |
- ( "SUM " "( " "DISTINCT "? Expression ") ") |
- |
- | | |
- ( "MIN " "( " "DISTINCT "? Expression ") ") |
- |
- | | |
- ( "MAX " "( " "DISTINCT "? Expression ") ") |
- |
- | | |
- ( "AVG " "( " "DISTINCT "? Expression ") ") |
- |
- | | |
- ( "SAMPLE " "( " "DISTINCT "? Expression ") ") |
- |
- | | |
- ( "GROUP_CONCAT " "( " "DISTINCT "? Expression ( "; " "SEPARATOR " "= " String) ? ") ") |
- |
[128] | -iriOrFunction |
- ::= | -iri ArgList? |
-
[129] | -RDFLiteral |
- ::= | -String ( LANGTAG | ( "^^ " iri) ) ? |
-
[130] | -NumericLiteral |
- ::= | -NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative |
-
[131] | -NumericLiteralUnsigned |
- ::= | -INTEGER | DECIMAL | DOUBLE |
-
[132] | -NumericLiteralPositive |
- ::= | -INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE |
-
[133] | -NumericLiteralNegative |
- ::= | -INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE |
-
[134] | -BooleanLiteral |
- ::= | -"true " | "false " |
-
[135] | -String |
- ::= | -STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2 |
-
[136] | -iri |
- ::= | -IRIREF | PrefixedName |
-
[137] | -PrefixedName |
- ::= | -PNAME_LN | PNAME_NS |
-
[138] | -BlankNode |
- ::= | -BLANK_NODE_LABEL | ANON |
-
@terminals | -
|
- - | # Productions for terminals | -
[139] | -IRIREF |
- ::= | -"< " ( [ ^<>"{}|^`\ ] - [ #x00 - #x20 ] ) * "> " |
-
[140] | -PNAME_NS |
- ::= | -PN_PREFIX? ": " |
-
[141] | -PNAME_LN |
- ::= | -PNAME_NS PN_LOCAL | -
[142] | -BLANK_NODE_LABEL |
- ::= | -"_: " ( PN_CHARS_U | [ 0-9 ] ) ( ( PN_CHARS | ". ") * PN_CHARS) ? |
-
[143] | -VAR1 |
- ::= | -"? " VARNAME |
-
[144] | -VAR2 |
- ::= | -"$ " VARNAME |
-
[145] | -LANGTAG |
- ::= | -"@ " [ a-zA-Z ] + ( "- " [ a-zA-Z0-9 ] + ) * |
-
[146] | -INTEGER |
- ::= | -[ 0-9 ] + |
-
[147] | -DECIMAL |
- ::= | -[ 0-9 ] * ". " [ 0-9 ] + |
-
[148] | -DOUBLE |
- ::= | -( [ 0-9 ] + ". " [ 0-9 ] * EXPONENT) | ( ". " [ 0-9 ] + EXPONENT) | ( [ 0-9 ] + EXPONENT) |
-
[149] | -INTEGER_POSITIVE |
- ::= | -"+ " INTEGER |
-
[150] | -DECIMAL_POSITIVE |
- ::= | -"+ " DECIMAL |
-
[151] | -DOUBLE_POSITIVE |
- ::= | -"+ " DOUBLE |
-
[152] | -INTEGER_NEGATIVE |
- ::= | -"- " INTEGER |
-
[153] | -DECIMAL_NEGATIVE |
- ::= | -"- " DECIMAL |
-
[154] | -DOUBLE_NEGATIVE |
- ::= | -"- " DOUBLE |
-
[155] | -EXPONENT |
- ::= | -[ eE ] [ +- ] ? [ 0-9 ] + |
-
[156] | -STRING_LITERAL1 |
- ::= | -"' " ( [ ^ #x27 #x5C #x0A #x0D ] | ECHAR) * "' " |
-
[157] | -STRING_LITERAL2 |
- ::= | -'" ' ( [ ^ #x22 #x5C #x0A #x0D ] | ECHAR) * '" ' |
-
[158] | -STRING_LITERAL_LONG1 |
- ::= | -"''' " ( ( "' " | "'' ") ? ( [ ^'\ ] | ECHAR) ) * "''' " |
-
[159] | -STRING_LITERAL_LONG2 |
- ::= | -'""" ' ( ( '" ' | '"" ') ? ( [ ^"\ ] | ECHAR) ) * '""" ' |
-
[160] | -ECHAR |
- ::= | -"\ " [ tbnrf"' ] |
-
[161] | -NIL |
- ::= | -"( " WS* ") " |
-
[162] | -WS |
- ::= | -#x20 | #x09 | #x0D | #x0A |
-
[163] | -ANON |
- ::= | -"[ " WS* "] " |
-
[164] | -PN_CHARS_BASE |
- ::= | -[ A-Za-z ] |
-
- | | |
- [ #xC0 - #xD6 ] |
- |
- | | |
- [ #xD8 - #xF6 ] |
- |
- | | |
- [ #xF8 - #x02FF ] |
- |
- | | |
- [ #x0370 - #x037D ] |
- |
- | | |
- [ #x037F - #x1FFF ] |
- |
- | | |
- [ #x200C - #x200D ] |
- |
- | | |
- [ #x2070 - #x218F ] |
- |
- | | |
- [ #x2C00 - #x2FEF ] |
- |
- | | |
- [ #x3001 - #xD7FF ] |
- |
- | | |
- [ #xF900 - #xFDCF ] |
- |
- | | |
- [ #xFDF0 - #xFFFD ] |
- |
- | | |
- [ #x00010000 - #x000EFFFF ] |
- |
[165] | -PN_CHARS_U |
- ::= | -PN_CHARS_BASE | "_ " |
-
[166] | -VARNAME |
- ::= | -( PN_CHARS_U | [ 0-9 ] ) ( PN_CHARS_U | [ 0-9 ] | #xB7 | [ #x0300 - #x036F ] | [ #x203F - #x2040 ] ) * |
-
[167] | -PN_CHARS |
- ::= | -PN_CHARS_U | "- " | [ 0-9 ] | #xB7 | [ #x0300 - #x036F ] | [ #x203F - #x2040 ] |
-
[168] | -PN_PREFIX |
- ::= | -PN_CHARS_BASE ( ( PN_CHARS | ". ") * PN_CHARS) ? |
-
[169] | -PN_LOCAL |
- ::= | -( PN_CHARS_U | [ 0-9 ] ) ( ( PN_CHARS | ". ") * PN_CHARS) ? |
-
[170] | -PLX |
- ::= | -PERCENT | PN_LOCAL_ESC |
-
[171] | -PERCENT |
- ::= | -"% " HEX HEX |
-
[172] | -HEX |
- ::= | -[ 0-9A-Fa-f ] |
-
[173] | -PN_LOCAL_ESC |
- ::= | -"\ " ( "_ " | "~ " | ". " | "- " | "! " | "$ " | "& " | "' " | "( " | ") " | "* " | "+ " | ", " | "; " | "= " | "/ " | "? " | "# " | "@ " | "% ") |
-
[1] | turtleDoc |
::= | statement* |
|
[2] | statement |
::= | -directive | ( triples ". ") |
+ directive | ( triples '. ') |
[3] | directive |
::= | prefixID | base | sparqlPrefix | sparqlBase |
|
[4] | prefixID |
::= | -"@prefix " PNAME_NS IRIREF ". " |
+ '@prefix ' PNAME_NS IRIREF '. ' |
[5] | base |
::= | -"@base " IRIREF ". " |
+ '@base ' IRIREF '. ' |
[28s] | sparqlPrefix |
::= | -SPARQL_PREFIX PNAME_NS IRIREF | +"PREFIX " PNAME_NS IRIREF |
[29s] | sparqlBase |
::= | -SPARQL_BASE IRIREF | +"BASE " IRIREF |
[6] | triples |
::= | ( subject predicateObjectList) | ( blankNodePropertyList predicateObjectList? ) |
|
[7] | predicateObjectList |
::= | -verb objectList ( "; " ( verb objectList) ? ) * |
+ verb objectList ( '; ' ( verb objectList) ? ) * |
[8] | objectList |
::= | -object ( ", " object) * |
+ object annotation? ( ', ' object annotation? ) * |
[9] | verb |
::= | -predicate | "a " |
+ predicate | 'a ' |
[10] | subject |
::= | -iri | BlankNode | collection |
+ iri | BlankNode | collection | quotedTriple |
[11] | predicate |
::= | iri | |
[12] | object |
::= | -iri | BlankNode | collection | blankNodePropertyList | literal |
+ iri | BlankNode | collection | blankNodePropertyList | literal | quotedTriple |
[13] | literal |
::= | RDFLiteral | NumericLiteral | BooleanLiteral |
|
[14] | blankNodePropertyList |
::= | -"[ " predicateObjectList "] " |
+ '[ ' predicateObjectList '] ' |
[15] | collection |
::= | -"( " object* ") " |
+ '( ' object* ') ' |
[16] | NumericLiteral |
::= | INTEGER | DECIMAL | DOUBLE |
|
[128s] | RDFLiteral |
::= | -String ( LANGTAG | ( "^^ " iri) ) ? |
+ String ( LANGTAG | ( '^^ ' iri) ) ? |
[133s] | BooleanLiteral |
::= | -"true " | "false " |
+ 'true ' | 'false ' |
[17] | String |
::= | STRING_LITERAL_QUOTE | STRING_LITERAL_SINGLE_QUOTE | STRING_LITERAL_LONG_SINGLE_QUOTE | STRING_LITERAL_LONG_QUOTE |
|
[135s] | iri |
::= | IRIREF | PrefixedName |
|
[136s] | PrefixedName |
::= | PNAME_LN | PNAME_NS |
|
[137s] | BlankNode |
::= | BLANK_NODE_LABEL | ANON |
|
quotedTriple |
+ ::= | +'<< ' qtSubject predicate qtObject '>> ' |
+ ||
qtSubject |
+ ::= | +iri | BlankNode | quotedTriple |
+ ||
qtObject |
+ ::= | +iri | BlankNode | literal | quotedTriple |
+ ||
annotation |
+ ::= | +'{| ' predicateObjectList '|} ' |
+ ||
@terminals |
|
@@ -152,237 +148,191 @@
# Productions for terminals | ||
[18] | IRIREF |
::= | -"< " ( ( [ ^<>"{}|^`\ ] - [ #x00 - #x20 ] ) | UCHAR) * "> " |
+ '< ' ( [ ^ #x00 - #x20 <>"{}|^`\ ] | UCHAR) * '> ' |
[139s] | PNAME_NS |
::= | -PN_PREFIX? ": " |
+ PN_PREFIX? ': ' |
[140s] | PNAME_LN |
::= | PNAME_NS PN_LOCAL | |
[141s] | BLANK_NODE_LABEL |
::= | -"_: " ( PN_CHARS_U | [ 0-9 ] ) ( ( PN_CHARS | ". ") * PN_CHARS) ? |
+ '_: ' ( PN_CHARS_U | [ 0-9 ] ) ( ( PN_CHARS | '. ') * PN_CHARS) ? |
[144s] | LANGTAG |
::= | -"@ " [ a-zA-Z ] + ( "- " [ a-zA-Z0-9 ] + ) * |
+ '@ ' [ a-zA-Z ] + ( '- ' [ a-zA-Z0-9 ] + ) * |
[19] | INTEGER |
::= | [ +- ] ? [ 0-9 ] + |
|
[20] | DECIMAL |
::= | -[ +- ] ? ( [ 0-9 ] * ". " [ 0-9 ] + ) |
+ [ +- ] ? ( [ 0-9 ] * '. ' [ 0-9 ] + ) |
[21] | DOUBLE |
::= | -[ +- ] ? ( ( [ 0-9 ] + ". " [ 0-9 ] * EXPONENT) | ( ". " [ 0-9 ] + EXPONENT) | ( [ 0-9 ] + EXPONENT) ) |
+ [ +- ] ? ( ( [ 0-9 ] + '. ' [ 0-9 ] * EXPONENT) | ( '. ' [ 0-9 ] + EXPONENT) | ( [ 0-9 ] + EXPONENT) ) |
[154s] | EXPONENT |
::= | [ eE ] [ +- ] ? [ 0-9 ] + |
|
[22] | STRING_LITERAL_QUOTE |
::= | -'" ' ( [ ^ #x22 #x5C #x0A #x0D ] | ECHAR | UCHAR) * '" ' |
+ '" ' ( [ ^ #x22 #x5C #x0A #x0D ] | ECHAR | UCHAR) * '" ' |
[23] | STRING_LITERAL_SINGLE_QUOTE |
::= | -"' " ( [ ^ #x27 #x5C #x0A #x0D ] | ECHAR | UCHAR) * "' " |
+ "' " ( [ ^ #x27 #x5C #x0A #x0D ] | ECHAR | UCHAR) * "' " |
[24] | STRING_LITERAL_LONG_SINGLE_QUOTE |
::= | "''' " ( ( "' " | "'' ") ? ( [ ^'\ ] | ECHAR | UCHAR) ) * "''' " |
|
[25] | STRING_LITERAL_LONG_QUOTE |
::= | '""" ' ( ( '" ' | '"" ') ? ( [ ^"\ ] | ECHAR | UCHAR) ) * '""" ' |
|
[26] | UCHAR |
::= | -( "u " HEX HEX HEX HEX) | ( "U " HEX HEX HEX HEX HEX HEX HEX HEX) |
+ ( '\u ' HEX HEX HEX HEX) | ( '\U ' HEX HEX HEX HEX HEX HEX HEX HEX) |
[159s] | ECHAR |
::= | -"\ " [ tbnrf"' ] |
- |
[28t] | -SPARQL_PREFIX |
- ::= | -[ Pp ] [ Rr ] [ Ee ] [ Ff ] [ Ii ] [ Xx ] |
+ '\ ' [ tbnrf\"' ] |
[29t] | -SPARQL_BASE |
+ |||
NIL |
::= | -[ Bb ] [ Aa ] [ Ss ] [ Ee ] |
+ '( ' WS* ') ' |
|
[161s] | WS |
::= | #x20 | #x09 | #x0D | #x0A |
|
[162s] | ANON |
::= | -"[ " WS* "] " |
+ '[ ' WS* '] ' |
[163s] | PN_CHARS_BASE |
::= | [ A-Z ] |
|
| |
[ a-z ] |
|||
| |
[ #xC0 - #xD6 ] |
|||
| |
[ #xD8 - #xF6 ] |
|||
| |
[ #xF8 - #x02FF ] |
|||
| |
[ #x0370 - #x037D ] |
|||
| |
[ #x037F - #x1FFF ] |
|||
| |
[ #x200C - #x200D ] |
|||
| |
[ #x2070 - #x218F ] |
|||
| |
[ #x2C00 - #x2FEF ] |
|||
| |
[ #x3001 - #xD7FF ] |
|||
| |
[ #xF900 - #xFDCF ] |
|||
| |
[ #xFDF0 - #xFFFD ] |
|||
| |
[ #x00010000 - #x000EFFFF ] |
|||
[164s] | PN_CHARS_U |
::= | -PN_CHARS_BASE | "_ " |
+ PN_CHARS_BASE | '_ ' |
[166s] | PN_CHARS |
::= | -PN_CHARS_U | "- " | [ 0-9 ] | #xB7 | [ #x0300 - #x036F ] | [ #x203F - #x2040 ] |
+ PN_CHARS_U | '- ' | [ 0-9 ] | #xB7 | [ #x0300 - #x036F ] | [ #x203F - #x2040 ] |
[167s] | PN_PREFIX |
::= | -PN_CHARS_BASE ( ( PN_CHARS | ". ") * PN_CHARS) ? |
+ PN_CHARS_BASE ( ( PN_CHARS | '. ') * PN_CHARS) ? |
[168s] | PN_LOCAL |
::= | -( PN_CHARS_U | ": " | [ 0-9 ] | PLX) ( ( PN_CHARS | ". " | ": " | PLX) * ( PN_CHARS | ": " | PLX) ) ? |
+ ( PN_CHARS_U | ': ' | [ 0-9 ] | PLX) ( ( PN_CHARS | '. ' | ': ' | PLX) * ( PN_CHARS | ': ' | PLX) ) ? |
[169s] | PLX |
::= | PERCENT | PN_LOCAL_ESC |
|
[170s] | PERCENT |
::= | -"% " HEX HEX |
+ '% ' HEX HEX |
[171s] | HEX |
::= | -[ 0-9A-Fa-f ] |
+ [ 0-9 ] | [ A-F ] | [ a-f ] |
[172s] | PN_LOCAL_ESC |
::= | -"\ " ( "_ " | "~ " | ". " | "- " | "! " | "$ " | "& " | "' " | "( " | ") " | "* " | "+ " | ", " | "; " | "= " | "/ " | "? " | "# " | "@ " | "% ") |
+ '\ ' ( '_ ' | '~ ' | '. ' | '- ' | "! " | '$ ' | '& ' | "' " | '( ' | ') ' | '* ' | '+ ' | ', ' | '; ' | '= ' | '/ ' | '? ' | '# ' | '@ ' | '% ') |
Produces an Abstract Synatx Tree in S-Expression form for the input grammar file
require 'ebnf'
-require 'ebnf/terminals'
-require 'ebnf/peg/parser'
-require 'core' # "Core" rules used in the ABNF spec.
-require 'meta' # "ABNF" rules used for parsing ABNF, itself
-require 'scanf'
-require 'logger'
-
-class ABNFParser
- include EBNF::PEG::Parser
Regular expressions for both "Core" and ABNF-specific terminals.
ALPHA = %r{[\x41-\x5A\x61-\x7A]}
- VCHAR = %r{[\x20-\x7E]}
- WSP = %r{[\x20\x09]}
- CRLF = %r{\x0D?\x0A}
- COMMENT = %r{;(?:#{WSP}|#{VCHAR})*#{CRLF}}
- C_NL = %r{#{COMMENT}|#{CRLF}}
- C_WSP = %r{#{WSP}|(?:#{C_NL}#{WSP})}
@return [Hash{Symbol => EBNF::Rule}]
attr_reader :parsed_rules
rulename ::= ALPHA (ALPHA | DIGIT | "-")*
terminal(:rulename, /#{ALPHA}(?:#{ALPHA}|[0-9-])*/) do |value|
- value.to_sym
- end
defined_as ::= c_wsp* ("=" | "=/") c_wsp*
terminal(:defined_as, /#{C_WSP}*=\/?#{C_WSP}*/) {|value| value.strip}
quoted_string::= DQUOTE [#x20-#x21#x23-#x7E]* DQUOTE
quoted_string ::= DQUOTE [#x20-#x21#x23-#x7E]* DQUOTE
terminal(:quoted_string, /"[\x20-\x21\x23-\x7E]*"/) do |value|
- value[1..-2]
- end
bin_val ::= "b" BIT+ (("." BIT+)+ | ("-" BIT+))?
terminal(:bin_val, /b[01]+(?:(?:(?:\.[01]+)+)|(?:-[01]+))?/) do |value|
- if value.include?('.')
Interpret segments in binary creating a sequence of hex characters or a string
hex_or_string(value[1..-1].split('.').map {|b| b.to_i(base=2).chr(Encoding::UTF_8)})
- elsif value.include?('-')
Interpret as a range
[:range, value[1..-1].split('-').map {|b| "#x%x" % b.to_i(base=2)}.join("-")]
- else
Interpret as a single HEX character
[:hex, "#x%x" % value[1..-1].to_i(base=2)]
- end
- end
dec_val ::= "d" DIGIT+ (("." DIGIT+)+ | ("-" DIGIT+))?
terminal(:dec_val, /d[0-9]+(?:(?:(?:\.[0-9]+)+)|(?:-[0-9]+))?/) do |value|
- if value.include?('.')
Interpret segments in decimal creating a sequence of hex characters or a string
hex_or_string(value[1..-1].split('.').map {|b| b.to_i.chr(Encoding::UTF_8)})
- elsif value.include?('-')
Interpret as a range
[:range, value[1..-1].split('-').map {|d| "#x%x" % d.to_i}.join("-")]
- else
Interpret as a single HEX character
[:hex, "#x%x" % value[1..-1].to_i]
- end
- end
hex_val ::= "x" HEXDIG+ (("." HEXDIG+)+ | ("-" HEXDIG+))?
terminal(:hex_val, /x[0-9A-F]+(?:(?:(?:\.[0-9A-F]+)+)|(?:-[0-9A-F]+))?/i) do |value|
- if value.include?('.')
Interpret segments in hexadecimal creating a sequence of hex characters or a string
hex_or_string(value[1..-1].split('.').map {|b| b.to_i(base=16).chr(Encoding::UTF_8)})
- elsif value.include?('-')
Interpret as a range
[:range, value[1..-1].split('-').map {|h| "#x%x" % h.to_i(base=16)}.join("-")]
- else
Interpret as a single HEX character
[:hex, "#x#{value[1..-1]}"]
- end
- end
c_wsp ::= WSP | (c_nl WSP)
terminal(:c_wsp, C_WSP)
c_nl ::= comment | CRLF
terminal(:c_nl, C_NL)
DIGIT ::= [#x30-#x39]
terminal(:DIGIT, /\d/)
The start_production
on :rule
allows the parser to present the value as a single Hash, rather than an array of individual hashes.
start_production(:rule, as_hash: true)
rule ::= rulename defined_as elements c_nl
production(:rule) do |value|
sym = value[:rulename]
- elements = value[:elements]
-
- if value[:defined_as] == "=/"
append to rule alternate
rule = parsed_rules.fetch(sym) {raise "No existing rule found for #{sym}"}
- rule.expr = [:alt, rule.expr] unless rule.alt?
- if elements.first == :alt
append alternatives to rule
rule.expr.concat(elements[1..-1])
- else
add elements as last alternative
rule.expr.push(elements)
- end
- else
There shouldn't be an existing rule
raise "Redefining rule #{sym}" if parsed_rules.has_key?(sym)
- parsed_rules[sym] = EBNF::Rule.new(sym.to_sym, nil, elements)
- end
- progress(:rule, level: 2) {parsed_rules[sym].to_sxp}
- sym
- end
elements ::= alternation c_wsp*
production(:elements) do |value|
- value.first[:alternation]
- end
alternation ::= concatenation (c_wsp* "/" c_wsp* concatenation)*
production(:alternation) do |value|
- unless value.last[:_alternation_1].empty?
- [:alt, value.first[:concatenation]] + value.last[:_alternation_1]
- else
- value.first[:concatenation]
- end
- end
The _aleteration_2
rule comes from the expanded PEG grammar and serves as an opportunity to custommize the values presented to the aleteration
rule.
production(:_alternation_2) do |value|
- if Array(value.last[:concatenation]).first == :alt
- value.last[:concatenation][1..-1]
- else
- [value.last[:concatenation]]
- end
- value.last[:concatenation]
- end
concatenation::= repetition (c_wsp+ repetition)*
production(:concatenation) do |value|
- unless value.last[:_concatenation_1].empty?
- [:seq, value.first[:repetition]] + value.last[:_concatenation_1]
- else
- value.first[:repetition]
- end
- end
- start_production(:_concatenation_2, as_hash: true)
- production(:_concatenation_2) do |value|
- value[:repetition]
- end
repetition ::= repeat? element
production(:repetition) do |value|
- rept = value.first[:_repetition_1]
- elt = value.last[:element]
- case rept
- when [0, '*'] then [:star, elt]
- when [1, '*'] then [:plus, elt]
- when nil then elt
- else
- [:rept, rept.first, rept.last, elt]
- end
- end
repeat ::= DIGIT+ | (DIGIT* "*" DIGIT*)
production(:repeat) do |value|
- if value.is_a?(Integer)
- [value, value]
- else
- [value.first, value.last]
- end
- end
- start_production(:_repeat_1, as_hash: true)
- production(:_repeat_1) {|value| value.values}
- production(:_repeat_2) {|value| value.join("").to_i}
- production(:_repeat_3) {|value| value.join("").to_i}
- production(:_repeat_4) {|value| value.length > 0 ? value.join("").to_i : '*'}
element ::= rulename | group | option | char_val | num_val | prose_val
production(:element) do |value|
- value
- end
group ::= "(" c_wsp* alternation c_wsp* ")"
start_production(:group, as_hash: true)
- production(:group) do |value|
- value[:alternation]
- end
option ::= "[" c_wsp* alternation c_wsp* "]"
start_production(:option, as_hash: true)
- production(:option) do |value|
- [:opt, value[:alternation]]
- end
case_insensitive_string ::= "%i"? quoted_string
production(:case_insensitive_string) do |value|
- str = value.last[:quoted_string]
- if str.match?(/[[:alpha:]]/)
Only need to use case-insensitive if there are alphabetic characters in the string.
[:istr, value.last[:quoted_string]]
- else
- value.last[:quoted_string]
- end
- end
case_sensitive_string ::= "%s" quoted_string
production(:case_sensitive_string) do |value|
- value.last[:quoted_string]
- end
num_val ::= "%" (bin_val | dec_val | hex_val)
production(:num_val) do |value|
- value.last[:_num_val_1]
- end
def initialize(input, **options, &block)
If the level
option is set, instantiate a logger for collecting trace information.
if options.has_key?(:level)
- options[:logger] = Logger.new(STDERR)
- options[:logger].level = options[:level]
- options[:logger].formatter = lambda {|severity, datetime, progname, msg| "#{severity} #{msg}\n"}
- end
Read input, if necessary, which will be used in a Scanner.
@input = input.respond_to?(:read) ? input.read : input.to_s
-
- @parsed_rules = {}
Parses into @parsed_rules
parse(@input,
- :rulelist, # Starting rule
- ABNFMeta::RULES, # PEG rules
- whitespace: '', # No implicit whitespace
- **options)
- end
@return [ArrayEBNF::Rule]
def ast
Add built-in rules for standard ABNF rules not
parsed_rules.values.map(&:symbols).flatten.uniq.each do |sym|
- rule = ABNFCore::RULES.detect {|r| r.sym == sym}
- parsed_rules[sym] ||= rule if rule
- end
-
- parsed_rules.values
- end
Output formatted S-Expression of grammar
+ +@return [String]
def to_sxp
- require 'sxp' unless defined?(SXP)
Output rules as a formatted S-Expression
SXP::Generator.string(ast.map(&:for_sxp))
- end
-
-private
def hex_or_string(characters)
- seq = [:seq]
- str_result = ""
- characters.each do |c|
- if VCHAR.match?(c)
- str_result << c
- else
- if str_result.length > 0
- seq << str_result
- str_result = ""
- end
- seq << [:hex, "#x%x" % c.hex]
- end
- end
- seq << str_result if str_result.length > 0
if seq.length == 2 && seq.last.is_a?(String)
- seq.last
- else
- seq
- end
- end
-end
|
) : "| "),
@@ -354,11 +354,12 @@ def format_ebnf(expr, sep: nil, embedded: false)
# Format a single-character string, prefering hex for non-main ASCII
def format_ebnf_char(c)
+ quote = c.as_dquote? ? '"' : "'"
case c.ord
- when (0x21) then (@options[:html] ? %("#{@coder.encode c}
") : %{"#{c}"})
+ when 0x21 then (@options[:html] ? %("#{@coder.encode c}
") : %{"#{c}"})
when 0x22 then (@options[:html] ? %('"
') : %{'"'})
- when (0x23..0x7e) then (@options[:html] ? %("#{@coder.encode c}
") : %{"#{c}"})
- when (0x80..0xFFFD) then (@options[:html] ? %("#{@coder.encode c}
") : %{"#{c}"})
+ when (0x23..0x7e) then (@options[:html] ? %(#{quote}#{@coder.encode c}
#{quote}) : %{#{quote}#{c}#{quote}})
+ when (0x80..0xFFFD) then (@options[:html] ? %(#{quote}#{@coder.encode c}
#{quote}) : %{#{quote}#{c}#{quote}})
else escape_ebnf_hex(c)
end
end
@@ -384,7 +385,8 @@ def format_ebnf_range(string)
end
# Escape a string, using as many UTF-8 characters as possible
- def format_ebnf_string(string, quote = '"')
+ def format_ebnf_string(string)
+ quote = string.as_dquote? ? '"' : "'"
string.each_char do |c|
case c.ord
when 0x00..0x19, quote.ord
diff --git a/spec/abnf_spec.rb b/spec/abnf_spec.rb
index 91eae38..26eda2e 100644
--- a/spec/abnf_spec.rb
+++ b/spec/abnf_spec.rb
@@ -156,7 +156,7 @@
],
"case sensitive": [
%(rulename = %s"aBc"),
- %{((rule rulename (seq "aBc")))}
+ %{((rule rulename (seq 'aBc')))}
],
}.each do |title, (input, expect)|
it title do
diff --git a/spec/base_spec.rb b/spec/base_spec.rb
index 73056e8..37af3fb 100644
--- a/spec/base_spec.rb
+++ b/spec/base_spec.rb
@@ -25,7 +25,7 @@
| STRING2
| '(' expression ')'
- } => %{((rule primary "9" (alt HEX RANGE O_RANGE STRING1 STRING2 (seq "(" expression ")"))))},
+ } => %{((rule primary "9" (alt HEX RANGE O_RANGE STRING1 STRING2 (seq '(' expression ')'))))},
%{#[1] rule ::= 'FOO'} => %{()},
%{//[1] rule ::= 'FOO'} => %{()},
%{[18] SolutionModifier ::= _SolutionModifier_1 _SolutionModifier_2} =>
@@ -33,7 +33,7 @@
%{[18.1] _SolutionModifier_1 ::= _empty | GroupClause} =>
%{((rule _SolutionModifier_1 "18.1" (alt _empty GroupClause)))},
%q{[18] STRING1 ::= '"' (CHAR - '"')* '"'} =>
- %q{((terminal STRING1 "18" (seq "\"" (star (diff CHAR "\"")) "\"")))},
+ %q{((terminal STRING1 "18" (seq '"' (star (diff CHAR '"')) '"')))},
%q{[161s] WS ::= #x20 | #x9 | #xD | #xA} =>
%q{((terminal WS "161s" (alt (hex "#x20") (hex "#x9") (hex "#xD") (hex "#xA"))))},
%q{[1] shexDoc ::= directive* # leading CODE} =>
diff --git a/spec/bnf_spec.rb b/spec/bnf_spec.rb
index f9278d1..08da265 100644
--- a/spec/bnf_spec.rb
+++ b/spec/bnf_spec.rb
@@ -24,7 +24,7 @@
} =>
%{((rule _empty "0" (seq))
(rule primary "9" (alt HEX RANGE O_RANGE STRING1 STRING2 _primary_1 ))
- (rule _primary_1 "9.1" (seq "(" expression ")")))},
+ (rule _primary_1 "9.1" (seq '(' expression ')')))},
%{
[1] R1 ::= 1 2
[2] R2 ::= 1 2
diff --git a/spec/ebnf_spec.rb b/spec/ebnf_spec.rb
index 1664976..20b93b2 100644
--- a/spec/ebnf_spec.rb
+++ b/spec/ebnf_spec.rb
@@ -21,7 +21,7 @@
| STRING1
| STRING2
| '(' expression ')'
- } => %{((rule primary "9" (alt HEX RANGE O_RANGE STRING1 STRING2 (seq "(" expression ")"))))},
+ } => %{((rule primary "9" (alt HEX RANGE O_RANGE STRING1 STRING2 (seq '(' expression ')'))))},
%{
primary ::= HEX
| RANGE
@@ -29,7 +29,7 @@
| STRING1
| STRING2
| '(' expression ')'
- } => %{((rule primary (alt HEX RANGE O_RANGE STRING1 STRING2 (seq "(" expression ")"))))},
+ } => %{((rule primary (alt HEX RANGE O_RANGE STRING1 STRING2 (seq '(' expression ')'))))},
}.each do |input, expected|
context input do
subject {EBNF.parse(input)}
diff --git a/spec/isoebnf_spec.rb b/spec/isoebnf_spec.rb
index ddb7fd1..c69f1db 100644
--- a/spec/isoebnf_spec.rb
+++ b/spec/isoebnf_spec.rb
@@ -80,11 +80,11 @@
"S" "T" "U" "V" "W" "X" "Y" "Z" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k"
"l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" ))
(rule digit (alt "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"))
- (rule symbol (alt "[" "]" "{" "}" "(" ")" "<" ">" "'" "\"" "=" "|" "." "," ";"))
+ (rule symbol (alt "[" "]" "{" "}" "(" ")" "<" ">" "'" '"' "=" "|" "." "," ";"))
(rule character (alt letter digit symbol "_"))
(rule identifier (seq letter (star (alt letter digit "_"))))
(rule terminal
- (alt (seq "'" character (star character) "'") (seq "\"" character (star character) "\"")))
+ (alt (seq "'" character (star character) "'") (seq '"' character (star character) '"')))
(rule lhs (seq identifier))
(rule rhs
(alt identifier terminal
@@ -116,11 +116,11 @@
all_characters = ? all visible characters ? ;
},
%q{((rule program
- (seq "PROGRAM" white_space identifier white_space "BEGIN" white_space
- (star (seq assignment ";" white_space)) "END." ))
+ (seq 'PROGRAM' white_space identifier white_space 'BEGIN' white_space
+ (star (seq assignment ";" white_space)) 'END.' ))
(rule identifier (seq alphabetic_character (star (alt alphabetic_character digit))))
(rule number (seq (opt "-") digit (star digit)))
- (rule string (seq "\"" (star (diff all_characters "\"")) "\""))
+ (rule string (seq '"' (star (diff all_characters '"')) '"'))
(rule assignment (seq identifier ":=" (seq (alt number identifier string))))
(rule alphabetic_character
(alt "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R"
diff --git a/spec/ll1/data/parser.rb b/spec/ll1/data/parser.rb
index 50fe07f..2eb6ae3 100644
--- a/spec/ll1/data/parser.rb
+++ b/spec/ll1/data/parser.rb
@@ -38,11 +38,11 @@ class EBNFParser
end
terminal(:STRING1, STRING1, unescape: true) do |prod, token, input|
- input[:terminal] = token.value[1..-2]
+ input[:terminal] = token.value[1..-2].tap {|s| s.quote_style = :dquote}
end
terminal(:STRING2, STRING2, unescape: true) do |prod, token, input|
- input[:terminal] = token.value[1..-2]
+ input[:terminal] = token.value[1..-2].tap {|s| s.quote_style = :squote}
end
terminal(:POSTFIX, POSTFIX) do |prod, token, input|
diff --git a/spec/ll1_spec.rb b/spec/ll1_spec.rb
index 7dbac19..1abdec7 100644
--- a/spec/ll1_spec.rb
+++ b/spec/ll1_spec.rb
@@ -75,7 +75,7 @@
},
%{
((rule _empty "0" (first _eps) (seq))
- (rule base "5" (first "@base") (seq "@base" IRIREF "."))
+ (rule base "5" (first '@base') (seq '@base' IRIREF "."))
(rule _base_1 "5.1" (seq IRIREF "."))
(rule _base_2 "5.2" (first ".") (seq ".")))
}, nil
@@ -88,7 +88,7 @@
},
%{(
(rule _empty "0" (first _eps) (seq))
- (terminal IRIREF "18" (seq "<" (star (alt "range" UCHAR)) ">"))
+ (terminal IRIREF "18" (seq '<' (star (alt "range" UCHAR)) '>'))
(rule sparqlBase "29s" (first SPARQL_BASE) (seq SPARQL_BASE IRIREF))
(terminal SPARQL_BASE "29t" (seq (range "Bb") (range "Aa") (range "Ss") (range "Ee")))
(rule _sparqlBase_1 "29s.1" (first IRIREF) (seq IRIREF)))
@@ -100,12 +100,12 @@
},
%{
((rule _empty "0" (first _eps) (seq))
- (rule declaration "2" (first "@pass" "@terminals") (alt "@terminals" "@pass")))
+ (rule declaration "2" (first '@pass' '@terminals') (alt '@terminals' '@pass')))
}, nil
],
"Query (FF.1/6)" => [
%{
- [2] Query ::= 'BASE'? 'SELECT'
+ [2] Query ::= "BASE"? "SELECT"
},
%{
((rule _empty "0" (first _eps) (seq))
@@ -133,7 +133,7 @@
%{
[18] SolutionModifier ::= _SolutionModifier_1
[18.1] _SolutionModifier_1 ::= _empty | GroupClause
- [19] GroupClause ::= 'GROUP'
+ [19] GroupClause ::= "GROUP"
},
%{
((rule _empty "0" (first _eps) (seq))
@@ -148,10 +148,10 @@
},
%[
((rule _empty "0" (first _eps) (seq) )
- (rule GroupGraphPattern "54" (first "{") (seq "{" _GroupGraphPattern_1 "}"))
- (rule _GroupGraphPattern_1 "54.1" (first "E" _eps) (follow "}") (cleanup opt) (alt _empty "E"))
- (rule _GroupGraphPattern_2 "54.2" (first "E" "}") (seq _GroupGraphPattern_1 "}"))
- (rule _GroupGraphPattern_3 "54.3" (first "}") (seq "}")))
+ (rule GroupGraphPattern "54" (first '{') (seq '{' _GroupGraphPattern_1 '}'))
+ (rule _GroupGraphPattern_1 "54.1" (first "E" _eps) (follow '}') (cleanup opt) (alt _empty "E"))
+ (rule _GroupGraphPattern_2 "54.2" (first "E" '}') (seq _GroupGraphPattern_1 '}'))
+ (rule _GroupGraphPattern_3 "54.3" (first '}') (seq '}')))
]
]
}.each do |name, (input, expected, start)|
@@ -233,15 +233,15 @@
},
%{
((rule _empty "0" (first _eps) (seq))
- (rule turtleDoc "1" (start #t) (first "BASE" "IRI" _eps) (follow _eof) (cleanup star)
+ (rule turtleDoc "1" (start #t) (first 'BASE' 'IRI' _eps) (follow _eof) (cleanup star)
(alt _empty _turtleDoc_1))
- (rule _turtleDoc_1 "1.1" (first "BASE" "IRI") (follow _eof) (cleanup merge) (seq statement turtleDoc))
- (rule _turtleDoc_2 "1.2" (first "BASE" "IRI" _eps) (follow _eof) (seq turtleDoc))
- (rule statement "2" (first "BASE" "IRI") (follow "BASE" "IRI" _eof) (alt directive _statement_1))
- (rule _statement_1 "2.1" (first "IRI") (follow "BASE" "IRI" _eof) (seq triples "."))
- (rule _statement_2 "2.2" (first ".") (follow "BASE" "IRI" _eof) (seq "."))
- (rule directive "3" (first "BASE") (follow "BASE" "IRI" _eof) (seq "BASE"))
- (rule triples "4" (first "IRI") (follow ".") (seq "IRI")))
+ (rule _turtleDoc_1 "1.1" (first 'BASE' 'IRI') (follow _eof) (cleanup merge) (seq statement turtleDoc))
+ (rule _turtleDoc_2 "1.2" (first 'BASE' 'IRI' _eps) (follow _eof) (seq turtleDoc))
+ (rule statement "2" (first 'BASE' 'IRI') (follow 'BASE' 'IRI' _eof) (alt directive _statement_1))
+ (rule _statement_1 "2.1" (first 'IRI') (follow 'BASE' 'IRI' _eof) (seq triples "."))
+ (rule _statement_2 "2.2" (first ".") (follow 'BASE' 'IRI' _eof) (seq "."))
+ (rule directive "3" (first 'BASE') (follow 'BASE' 'IRI' _eof) (seq 'BASE'))
+ (rule triples "4" (first 'IRI') (follow ".") (seq 'IRI')))
}, :turtleDoc
]
}.each do |name, (input, expected, start)|
diff --git a/spec/native_spec.rb b/spec/native_spec.rb
index 8c71fea..87e5497 100644
--- a/spec/native_spec.rb
+++ b/spec/native_spec.rb
@@ -22,7 +22,7 @@
],
"aliteration": [
%{[2] declaration ::= '@terminals' | '@pass'},
- %{((rule declaration "2" (alt "@terminals" "@pass")))},
+ %{((rule declaration "2" (alt '@terminals' '@pass')))},
],
"posfix": [
%{[9] postfix ::= primary ( [?*+] )?},
@@ -35,12 +35,12 @@
"IRIREF": [
%([18] IRIREF ::= '<' ([^<>"{}|^`\]-[#x00-#x20] | UCHAR)* '>'),
%{((terminal IRIREF "18"
- (seq "<"
+ (seq '<'
(star
(alt
(diff (range "^<>\\\"{}|^`") (range "#x00-#x20"))
UCHAR))
- ">")))},
+ '>')))},
],
}.each do |title, (input, expect)|
it title do
@@ -56,7 +56,7 @@
],
"aliteration": [
%{declaration ::= '@terminals' | '@pass'},
- %{((rule declaration (alt "@terminals" "@pass")))},
+ %{((rule declaration (alt '@terminals' '@pass')))},
],
"posfix": [
%{postfix ::= primary ( [?*+] )?},
@@ -69,12 +69,12 @@
"IRIREF": [
%(IRIREF ::= '<' ([^<>"{}|^`\]-[#x00-#x20] | UCHAR)* '>'),
%{((terminal IRIREF
- (seq "<"
+ (seq '<'
(star
(alt
(diff (range "^<>\\\"{}|^`") (range "#x00-#x20"))
UCHAR))
- ">")))},
+ '>')))},
],
}.each do |title, (input, expect)|
it title do
@@ -86,7 +86,7 @@
describe "#expression" do
{
- "'abc' def" => %{(seq "abc" def)},
+ "'abc' def" => %{(seq 'abc' def)},
%{[0-9]} => %{(range "0-9")},
%{#x00B7} => %{(hex "#x00B7")},
%{[#x0300-#x036F]} => %{(range "#x0300-#x036F")},
@@ -103,9 +103,9 @@
%{a b | c d} => %{(alt (seq a b) (seq c d))},
%{BaseDecl? PrefixDecl*} => %{(seq (opt BaseDecl) (star PrefixDecl))},
%{NCCHAR1 | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]} =>
- %{(alt NCCHAR1 "-" (range "0-9") (hex "#x00B7") (range "#x0300-#x036F") (range "#x203F-#x2040"))},
+ %{(alt NCCHAR1 '-' (range "0-9") (hex "#x00B7") (range "#x0300-#x036F") (range "#x203F-#x2040"))},
%{'<' ([^<>"{}|^`\]-[#x00-#x20] | UCHAR)* '>'} =>
- %{(seq "<" (star (alt (diff (range "^<>\\\"{}|^`") (range "#x00-#x20")) UCHAR)) ">")}
+ %{(seq '<' (star (alt (diff (range "^<>\\\"{}|^`") (range "#x00-#x20")) UCHAR)) '>')}
}.each do |input, expected|
it "given #{input.inspect} produces #{expected}" do
rule = parse("rule ::= #{input}").ast.first
diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb
index c72935b..3213000 100644
--- a/spec/parser_spec.rb
+++ b/spec/parser_spec.rb
@@ -22,7 +22,7 @@
],
"aliteration": [
%{[2] declaration ::= '@terminals' | '@pass'},
- %{((rule declaration "2" (alt "@terminals" "@pass")))},
+ %{((rule declaration "2" (alt '@terminals' '@pass')))},
],
"posfix": [
%{[9] postfix ::= primary ( [?*+] )?},
@@ -35,12 +35,12 @@
"IRIREF": [
%([18] IRIREF ::= '<' ([^<>"{}|^`\]-[#x00-#x20] | UCHAR)* '>'),
%{((terminal IRIREF "18"
- (seq "<"
+ (seq '<'
(star
(alt
(diff (range "^<>\\\"{}|^`") (range "#x00-#x20"))
UCHAR))
- ">")))},
+ '>')))},
],
"minimal whitespace": [
%{[xx]minimal::=whitespace[yy]whitespace::=PASS},
@@ -61,7 +61,7 @@
],
"aliteration": [
%{declaration ::= '@terminals' | '@pass'},
- %{((rule declaration (alt "@terminals" "@pass")))},
+ %{((rule declaration (alt '@terminals' '@pass')))},
],
"posfix": [
%{postfix ::= primary ( [?*+] )?},
@@ -74,12 +74,12 @@
"IRIREF": [
%(IRIREF ::= '<' ([^<>"{}|^`\]-[#x00-#x20] | UCHAR)* '>'),
%{((terminal IRIREF
- (seq "<"
+ (seq '<'
(star
(alt
(diff (range "^<>\\\"{}|^`") (range "#x00-#x20"))
UCHAR))
- ">")))},
+ '>')))},
],
}.each do |title, (input, expect)|
it title do
@@ -91,7 +91,7 @@
describe "#expression" do
{
- "'abc' def" => %{(seq "abc" def)},
+ "'abc' def" => %{(seq 'abc' def)},
%{[0-9]} => %{(range "0-9")},
%{#x00B7} => %{(hex "#x00B7")},
%{[#x0300-#x036F]} => %{(range "#x0300-#x036F")},
@@ -114,9 +114,9 @@
%{[#x20#x21#x22]} => %{(range "#x20#x21#x22")},
%{BaseDecl? PrefixDecl*} => %{(seq (opt BaseDecl) (star PrefixDecl))},
%{NCCHAR1 | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]} =>
- %{(alt NCCHAR1 "-" (range "0-9") (hex "#x00B7") (range "#x0300-#x036F") (range "#x203F-#x2040"))},
+ %{(alt NCCHAR1 '-' (range "0-9") (hex "#x00B7") (range "#x0300-#x036F") (range "#x203F-#x2040"))},
%{'<' ([^<>"{}|^`\]-[#x00-#x20] | UCHAR)* '>'} =>
- %{(seq "<" (star (alt (diff (range "^<>\\\"{}|^`") (range "#x00-#x20")) UCHAR)) ">")},
+ %{(seq '<' (star (alt (diff (range "^<>\\\"{}|^`") (range "#x00-#x20")) UCHAR)) '>')},
}.each do |input, expected|
it "given #{input.inspect} produces #{expected}" do
rule = parse("rule ::= #{input}").ast.first
diff --git a/spec/peg/data/parser.rb b/spec/peg/data/parser.rb
index 4f652ed..2fe4807 100644
--- a/spec/peg/data/parser.rb
+++ b/spec/peg/data/parser.rb
@@ -35,11 +35,11 @@ class EBNFPegParser
end
terminal(:STRING1, STRING1, unescape: true) do |value|
- value[1..-2]
+ value[1..-2].tap {|s| s.quote_style = :dquote}
end
terminal(:STRING2, STRING2, unescape: true) do |value|
- value[1..-2]
+ value[1..-2].tap {|s| s.quote_style = :squote}
end
terminal(:POSTFIX, POSTFIX)
diff --git a/spec/peg_spec.rb b/spec/peg_spec.rb
index 5d06e47..c8ad6e2 100644
--- a/spec/peg_spec.rb
+++ b/spec/peg_spec.rb
@@ -21,7 +21,7 @@
} =>
%{((rule primary "9" (alt HEX RANGE O_RANGE STRING1 STRING2 _primary_1))
- (rule _primary_1 "9.1" (seq "(" expression ")")))},
+ (rule _primary_1 "9.1" (seq '(' expression ')')))},
%{[1] start ::= A B C} =>
%{((rule start "1" (seq A B C)))},
%{[1] start ::= A B? C* D+} =>
diff --git a/spec/rule_spec.rb b/spec/rule_spec.rb
index a11f56a..eba5e97 100644
--- a/spec/rule_spec.rb
+++ b/spec/rule_spec.rb
@@ -480,8 +480,8 @@
describe "#to_regexp" do
{
- hex: [:hex, "#x20", / /],
- hex: [:hex, "#x5c", /\\/],
+ hex: [:hex, "#x20", /\ /],
+ hex2: [:hex, "#x5c", /\\/],
range: [:range, "a-b", /[a-b]/],
range2: [:range, "a-zA-Z", /[a-zA-Z]/],
range3: [:range, "abc-", /[abc-]/],
diff --git a/spec/writer_spec.rb b/spec/writer_spec.rb
index d507333..34ed449 100644
--- a/spec/writer_spec.rb
+++ b/spec/writer_spec.rb
@@ -84,7 +84,19 @@
'//tbody/tr/td[1]/text()': "[2]",
'//tbody/tr/td[2]/code/text()': "Prolog",
'//tbody/tr/td[3]/text()': "::=",
- #'//tbody/tr/td[4]/*/text()': /BaseDecl\? PrefixDecl\*/,
+ #'//tbody/tr/td[4]/text()': /BaseDecl\? PrefixDecl\*/,
+ }
+ ],
+ statement: [
+ %{[2] statement ::= directive | triples '.'},
+ {
+ '//table/@class': "grammar",
+ '//table/tbody/@id': "grammar-productions",
+ '//tbody/tr/@id': "grammar-production-statement",
+ '//tbody/tr/td[1]/text()': "[2]",
+ '//tbody/tr/td[2]/code/text()': "statement",
+ '//tbody/tr/td[3]/text()': "::=",
+ #'//tbody/tr/td[4]/text()': /directive | triples '.'/,
}
],
}.each do |title, (grammar, xpaths)|
@@ -103,20 +115,20 @@
context "EBNF" do
describe "#initialize" do
{
- prolog: [
- %{[2] Prolog ::= BaseDecl? PrefixDecl*},
- %{[2] Prolog ::= BaseDecl? PrefixDecl*\n}
- ],
- backslash: [
- %{LHS ::= [^'\] | ECHAR},
- %{LHS ::= [^'\] | ECHAR\n}
- ]
- }.each do |title, (grammar, plain)|
+ prolog: {
+ ebnf: %{[2] Prolog ::= BaseDecl? PrefixDecl*},
+ plain: %{[2] Prolog ::= BaseDecl? PrefixDecl*\n}
+ },
+ backslash: {
+ ebnf: %{LHS ::= [^'\] | ECHAR},
+ plain: %{LHS ::= [^'\] | ECHAR}
+ }
+ }.each do |title, params|
context title do
- subject {EBNF::Base.new(grammar, format: :native).ast}
+ subject {EBNF::Base.new(params[:ebnf], format: :native).ast}
it "generates plain" do
- expect {EBNF::Writer.new(subject)}.to write(plain).to(:output)
+ expect {EBNF::Writer.new(subject)}.to write(params[:plain]).to(:output)
end
end
end
@@ -143,6 +155,10 @@
[:istr, "foo"],
%("foo")
],
+ "str": [
+ 'foo',
+ %("foo")
+ ],
"opt": [
[:opt, :A],
"A?"