Skip to content

Commit

Permalink
Keep single-quote and double-quote strings separate. (Depends on upda…
Browse files Browse the repository at this point in the history
…ted support in SXP).
  • Loading branch information
gkellogg committed Oct 19, 2023
1 parent f998d3d commit 2a591ad
Show file tree
Hide file tree
Showing 47 changed files with 929 additions and 13,134 deletions.
18 changes: 9 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,27 @@ 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
%x(cp etc/ebnf.peg.rb lib/ebnf/ebnf/meta.rb)
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


# Build SXP output with leading space to allow for Markdown formatting.
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
Expand All @@ -89,32 +89,32 @@ 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
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
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
2 changes: 1 addition & 1 deletion etc/abnf.sxp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
26 changes: 13 additions & 13 deletions etc/ebnf.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion etc/ebnf.ll1.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
188 changes: 94 additions & 94 deletions etc/ebnf.ll1.sxp
Original file line number Diff line number Diff line change
Expand Up @@ -2,181 +2,181 @@
(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
(range "#x9#xA#xD")
(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 ')')) )
2 changes: 1 addition & 1 deletion etc/ebnf.peg.rb
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
Loading

0 comments on commit 2a591ad

Please sign in to comment.