ebnf 1.1.2 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +218 -196
- data/UNLICENSE +1 -1
- data/VERSION +1 -1
- data/bin/ebnf +40 -21
- data/etc/abnf-core.ebnf +52 -0
- data/etc/abnf.abnf +121 -0
- data/etc/abnf.ebnf +124 -0
- data/etc/abnf.sxp +45 -0
- data/etc/doap.ttl +23 -15
- data/etc/ebnf.ebnf +21 -33
- data/etc/ebnf.html +171 -160
- data/etc/{ebnf.rb → ebnf.ll1.rb} +30 -107
- data/etc/ebnf.ll1.sxp +182 -183
- data/etc/ebnf.peg.rb +90 -0
- data/etc/ebnf.peg.sxp +84 -0
- data/etc/ebnf.sxp +40 -41
- data/etc/iso-ebnf.ebnf +140 -0
- data/etc/iso-ebnf.isoebnf +138 -0
- data/etc/iso-ebnf.sxp +65 -0
- data/etc/sparql.ebnf +4 -4
- data/etc/sparql.html +1603 -1751
- data/etc/sparql.ll1.sxp +7372 -7372
- data/etc/sparql.peg.rb +532 -0
- data/etc/sparql.peg.sxp +597 -0
- data/etc/sparql.sxp +363 -362
- data/etc/turtle.ebnf +3 -3
- data/etc/turtle.html +465 -517
- data/etc/{turtle.rb → turtle.ll1.rb} +3 -4
- data/etc/turtle.ll1.sxp +425 -425
- data/etc/turtle.peg.rb +182 -0
- data/etc/turtle.peg.sxp +199 -0
- data/etc/turtle.sxp +103 -101
- data/lib/ebnf.rb +7 -2
- data/lib/ebnf/abnf.rb +301 -0
- data/lib/ebnf/abnf/core.rb +23 -0
- data/lib/ebnf/abnf/meta.rb +111 -0
- data/lib/ebnf/base.rb +128 -87
- data/lib/ebnf/bnf.rb +1 -26
- data/lib/ebnf/ebnf/meta.rb +90 -0
- data/lib/ebnf/isoebnf.rb +229 -0
- data/lib/ebnf/isoebnf/meta.rb +75 -0
- data/lib/ebnf/ll1.rb +140 -8
- data/lib/ebnf/ll1/lexer.rb +37 -32
- data/lib/ebnf/ll1/parser.rb +113 -73
- data/lib/ebnf/ll1/scanner.rb +83 -51
- data/lib/ebnf/native.rb +320 -0
- data/lib/ebnf/parser.rb +285 -302
- data/lib/ebnf/peg.rb +39 -0
- data/lib/ebnf/peg/parser.rb +561 -0
- data/lib/ebnf/peg/rule.rb +241 -0
- data/lib/ebnf/rule.rb +453 -163
- data/lib/ebnf/terminals.rb +21 -0
- data/lib/ebnf/writer.rb +561 -88
- metadata +114 -28
- data/etc/sparql.rb +0 -45773
data/etc/ebnf.peg.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# This file is automatically generated by ebnf version 2.0.0
|
2
|
+
# Derived from etc/ebnf.ebnf
|
3
|
+
module EBNFMeta
|
4
|
+
RULES = [
|
5
|
+
EBNF::Rule.new(:ebnf, "1", [:star, :_ebnf_1]).extend(EBNF::PEG::Rule),
|
6
|
+
EBNF::Rule.new(:_ebnf_1, "1.1", [:alt, :declaration, :rule]).extend(EBNF::PEG::Rule),
|
7
|
+
EBNF::Rule.new(:declaration, "2", [:alt, "@terminals", :pass]).extend(EBNF::PEG::Rule),
|
8
|
+
EBNF::Rule.new(:rule, "3", [:seq, :LHS, :expression]).extend(EBNF::PEG::Rule),
|
9
|
+
EBNF::Rule.new(:expression, "4", [:seq, :alt]).extend(EBNF::PEG::Rule),
|
10
|
+
EBNF::Rule.new(:alt, "5", [:seq, :seq, :_alt_1]).extend(EBNF::PEG::Rule),
|
11
|
+
EBNF::Rule.new(:_alt_1, "5.1", [:star, :_alt_2]).extend(EBNF::PEG::Rule),
|
12
|
+
EBNF::Rule.new(:_alt_2, "5.2", [:seq, "|", :seq]).extend(EBNF::PEG::Rule),
|
13
|
+
EBNF::Rule.new(:seq, "6", [:plus, :diff]).extend(EBNF::PEG::Rule),
|
14
|
+
EBNF::Rule.new(:diff, "7", [:seq, :postfix, :_diff_1]).extend(EBNF::PEG::Rule),
|
15
|
+
EBNF::Rule.new(:_diff_1, "7.1", [:opt, :_diff_2]).extend(EBNF::PEG::Rule),
|
16
|
+
EBNF::Rule.new(:_diff_2, "7.2", [:seq, "-", :postfix]).extend(EBNF::PEG::Rule),
|
17
|
+
EBNF::Rule.new(:postfix, "8", [:seq, :primary, :_postfix_1]).extend(EBNF::PEG::Rule),
|
18
|
+
EBNF::Rule.new(:_postfix_1, "8.1", [:opt, :POSTFIX]).extend(EBNF::PEG::Rule),
|
19
|
+
EBNF::Rule.new(:primary, "9", [:alt, :HEX, :SYMBOL, :O_RANGE, :RANGE, :STRING1, :STRING2, :_primary_1]).extend(EBNF::PEG::Rule),
|
20
|
+
EBNF::Rule.new(:_primary_1, "9.1", [:seq, "(", :expression, ")"]).extend(EBNF::PEG::Rule),
|
21
|
+
EBNF::Rule.new(:pass, "10", [:seq, "@pass", :expression]).extend(EBNF::PEG::Rule),
|
22
|
+
EBNF::Rule.new(:_terminals, nil, [:seq], kind: :terminals).extend(EBNF::PEG::Rule),
|
23
|
+
EBNF::Rule.new(:LHS, "11", [:seq, :_LHS_1, :SYMBOL, :_LHS_2, "::="], kind: :terminal).extend(EBNF::PEG::Rule),
|
24
|
+
EBNF::Rule.new(:_LHS_1, "11.1", [:opt, :_LHS_3], kind: :terminal).extend(EBNF::PEG::Rule),
|
25
|
+
EBNF::Rule.new(:_LHS_3, "11.3", [:seq, "[", :SYMBOL, "]", :_LHS_4], kind: :terminal).extend(EBNF::PEG::Rule),
|
26
|
+
EBNF::Rule.new(:_LHS_4, "11.4", [:plus, " "], kind: :terminal).extend(EBNF::PEG::Rule),
|
27
|
+
EBNF::Rule.new(:_LHS_2, "11.2", [:star, " "], kind: :terminal).extend(EBNF::PEG::Rule),
|
28
|
+
EBNF::Rule.new(:SYMBOL, "12", [:plus, :_SYMBOL_1], kind: :terminal).extend(EBNF::PEG::Rule),
|
29
|
+
EBNF::Rule.new(:_SYMBOL_1, "12.1", [:alt, :_SYMBOL_2, :_SYMBOL_3, :_SYMBOL_4, "_", "."], kind: :terminal).extend(EBNF::PEG::Rule),
|
30
|
+
EBNF::Rule.new(:_SYMBOL_2, "12.2", [:range, "a-z"], kind: :terminal).extend(EBNF::PEG::Rule),
|
31
|
+
EBNF::Rule.new(:_SYMBOL_3, "12.3", [:range, "A-Z"], kind: :terminal).extend(EBNF::PEG::Rule),
|
32
|
+
EBNF::Rule.new(:_SYMBOL_4, "12.4", [:range, "0-9"], kind: :terminal).extend(EBNF::PEG::Rule),
|
33
|
+
EBNF::Rule.new(:HEX, "13", [:seq, "#x", :_HEX_1], kind: :terminal).extend(EBNF::PEG::Rule),
|
34
|
+
EBNF::Rule.new(:_HEX_1, "13.1", [:plus, :_HEX_2], kind: :terminal).extend(EBNF::PEG::Rule),
|
35
|
+
EBNF::Rule.new(:_HEX_2, "13.2", [:alt, :_HEX_3, :_HEX_4, :_HEX_5], kind: :terminal).extend(EBNF::PEG::Rule),
|
36
|
+
EBNF::Rule.new(:_HEX_3, "13.3", [:range, "a-f"], kind: :terminal).extend(EBNF::PEG::Rule),
|
37
|
+
EBNF::Rule.new(:_HEX_4, "13.4", [:range, "A-F"], kind: :terminal).extend(EBNF::PEG::Rule),
|
38
|
+
EBNF::Rule.new(:_HEX_5, "13.5", [:range, "0-9"], kind: :terminal).extend(EBNF::PEG::Rule),
|
39
|
+
EBNF::Rule.new(:RANGE, "14", [:seq, "[", :_RANGE_1, :_RANGE_2, :_RANGE_3], kind: :terminal).extend(EBNF::PEG::Rule),
|
40
|
+
EBNF::Rule.new(:_RANGE_1, "14.1", [:plus, :_RANGE_4], kind: :terminal).extend(EBNF::PEG::Rule),
|
41
|
+
EBNF::Rule.new(:_RANGE_4, "14.4", [:alt, :_RANGE_5, :_RANGE_6, :R_CHAR, :HEX], kind: :terminal).extend(EBNF::PEG::Rule),
|
42
|
+
EBNF::Rule.new(:_RANGE_5, "14.5", [:seq, :R_CHAR, "-", :R_CHAR], kind: :terminal).extend(EBNF::PEG::Rule),
|
43
|
+
EBNF::Rule.new(:_RANGE_6, "14.6", [:seq, :HEX, "-", :HEX], kind: :terminal).extend(EBNF::PEG::Rule),
|
44
|
+
EBNF::Rule.new(:_RANGE_2, "14.2", [:opt, "-"], kind: :terminal).extend(EBNF::PEG::Rule),
|
45
|
+
EBNF::Rule.new(:_RANGE_3, "14.3", [:diff, "]", :LHS], kind: :terminal).extend(EBNF::PEG::Rule),
|
46
|
+
EBNF::Rule.new(:O_RANGE, "15", [:seq, "[^", :_O_RANGE_1, :_O_RANGE_2, "]"], kind: :terminal).extend(EBNF::PEG::Rule),
|
47
|
+
EBNF::Rule.new(:_O_RANGE_1, "15.1", [:plus, :_O_RANGE_3], kind: :terminal).extend(EBNF::PEG::Rule),
|
48
|
+
EBNF::Rule.new(:_O_RANGE_3, "15.3", [:alt, :_O_RANGE_4, :_O_RANGE_5, :R_CHAR, :HEX], kind: :terminal).extend(EBNF::PEG::Rule),
|
49
|
+
EBNF::Rule.new(:_O_RANGE_4, "15.4", [:seq, :R_CHAR, "-", :R_CHAR], kind: :terminal).extend(EBNF::PEG::Rule),
|
50
|
+
EBNF::Rule.new(:_O_RANGE_5, "15.5", [:seq, :HEX, "-", :HEX], kind: :terminal).extend(EBNF::PEG::Rule),
|
51
|
+
EBNF::Rule.new(:_O_RANGE_2, "15.2", [:opt, "-"], kind: :terminal).extend(EBNF::PEG::Rule),
|
52
|
+
EBNF::Rule.new(:STRING1, "16", [:seq, "\"", :_STRING1_1, "\""], kind: :terminal).extend(EBNF::PEG::Rule),
|
53
|
+
EBNF::Rule.new(:_STRING1_1, "16.1", [:star, :_STRING1_2], kind: :terminal).extend(EBNF::PEG::Rule),
|
54
|
+
EBNF::Rule.new(:_STRING1_2, "16.2", [:diff, :CHAR, "\""], kind: :terminal).extend(EBNF::PEG::Rule),
|
55
|
+
EBNF::Rule.new(:STRING2, "17", [:seq, "'", :_STRING2_1, "'"], kind: :terminal).extend(EBNF::PEG::Rule),
|
56
|
+
EBNF::Rule.new(:_STRING2_1, "17.1", [:star, :_STRING2_2], kind: :terminal).extend(EBNF::PEG::Rule),
|
57
|
+
EBNF::Rule.new(:_STRING2_2, "17.2", [:diff, :CHAR, "'"], kind: :terminal).extend(EBNF::PEG::Rule),
|
58
|
+
EBNF::Rule.new(:CHAR, "18", [:alt, :_CHAR_1, :_CHAR_2, :_CHAR_3, :_CHAR_4], kind: :terminal).extend(EBNF::PEG::Rule),
|
59
|
+
EBNF::Rule.new(:_CHAR_1, "18.1", [:range, "#x9#xA#xD"], kind: :terminal).extend(EBNF::PEG::Rule),
|
60
|
+
EBNF::Rule.new(:_CHAR_2, "18.2", [:range, "#x20-#xD7FF"], kind: :terminal).extend(EBNF::PEG::Rule),
|
61
|
+
EBNF::Rule.new(:_CHAR_3, "18.3", [:range, "#xE000-#xFFFD"], kind: :terminal).extend(EBNF::PEG::Rule),
|
62
|
+
EBNF::Rule.new(:_CHAR_4, "18.4", [:range, "#x10000-#x10FFFF"], kind: :terminal).extend(EBNF::PEG::Rule),
|
63
|
+
EBNF::Rule.new(:R_CHAR, "19", [:diff, :CHAR, :_R_CHAR_1], kind: :terminal).extend(EBNF::PEG::Rule),
|
64
|
+
EBNF::Rule.new(:_R_CHAR_1, "19.1", [:alt, "]", "-", :HEX], kind: :terminal).extend(EBNF::PEG::Rule),
|
65
|
+
EBNF::Rule.new(:POSTFIX, "20", [:range, "?*+"], kind: :terminal).extend(EBNF::PEG::Rule),
|
66
|
+
EBNF::Rule.new(:PASS, "21", [:alt, :_PASS_1, :_PASS_2, :_PASS_3, :_PASS_4], kind: :terminal).extend(EBNF::PEG::Rule),
|
67
|
+
EBNF::Rule.new(:_PASS_1, "21.1", [:range, "#x9#xA#xD#x20"], kind: :terminal).extend(EBNF::PEG::Rule),
|
68
|
+
EBNF::Rule.new(:_PASS_2, "21.2", [:seq, :_PASS_5, :_PASS_6], kind: :terminal).extend(EBNF::PEG::Rule),
|
69
|
+
EBNF::Rule.new(:_PASS_5, "21.5", [:alt, :_PASS_7, "//"], kind: :terminal).extend(EBNF::PEG::Rule),
|
70
|
+
EBNF::Rule.new(:_PASS_7, "21.7", [:diff, "#", "#x"], kind: :terminal).extend(EBNF::PEG::Rule),
|
71
|
+
EBNF::Rule.new(:_PASS_6, "21.6", [:star, :_PASS_8], kind: :terminal).extend(EBNF::PEG::Rule),
|
72
|
+
EBNF::Rule.new(:_PASS_8, "21.8", [:range, "^#xA#xD"], kind: :terminal).extend(EBNF::PEG::Rule),
|
73
|
+
EBNF::Rule.new(:_PASS_3, "21.3", [:seq, "/*", :_PASS_9, "*/"], kind: :terminal).extend(EBNF::PEG::Rule),
|
74
|
+
EBNF::Rule.new(:_PASS_9, "21.9", [:star, :_PASS_10], kind: :terminal).extend(EBNF::PEG::Rule),
|
75
|
+
EBNF::Rule.new(:_PASS_10, "21.10", [:alt, :_PASS_11, :_PASS_12], kind: :terminal).extend(EBNF::PEG::Rule),
|
76
|
+
EBNF::Rule.new(:_PASS_11, "21.11", [:opt, :_PASS_13], kind: :terminal).extend(EBNF::PEG::Rule),
|
77
|
+
EBNF::Rule.new(:_PASS_13, "21.13", [:seq, "*", :_PASS_14], kind: :terminal).extend(EBNF::PEG::Rule),
|
78
|
+
EBNF::Rule.new(:_PASS_14, "21.14", [:range, "^/"], kind: :terminal).extend(EBNF::PEG::Rule),
|
79
|
+
EBNF::Rule.new(:_PASS_12, "21.12", [:range, "^*"], kind: :terminal).extend(EBNF::PEG::Rule),
|
80
|
+
EBNF::Rule.new(:_PASS_4, "21.4", [:seq, "(*", :_PASS_15, "*)"], kind: :terminal).extend(EBNF::PEG::Rule),
|
81
|
+
EBNF::Rule.new(:_PASS_15, "21.15", [:star, :_PASS_16], kind: :terminal).extend(EBNF::PEG::Rule),
|
82
|
+
EBNF::Rule.new(:_PASS_16, "21.16", [:alt, :_PASS_17, :_PASS_18], kind: :terminal).extend(EBNF::PEG::Rule),
|
83
|
+
EBNF::Rule.new(:_PASS_17, "21.17", [:opt, :_PASS_19], kind: :terminal).extend(EBNF::PEG::Rule),
|
84
|
+
EBNF::Rule.new(:_PASS_19, "21.19", [:seq, "*", :_PASS_20], kind: :terminal).extend(EBNF::PEG::Rule),
|
85
|
+
EBNF::Rule.new(:_PASS_20, "21.20", [:range, "^)"], kind: :terminal).extend(EBNF::PEG::Rule),
|
86
|
+
EBNF::Rule.new(:_PASS_18, "21.18", [:range, "^*"], kind: :terminal).extend(EBNF::PEG::Rule),
|
87
|
+
EBNF::Rule.new(:_pass, nil, [:seq, :PASS], kind: :pass).extend(EBNF::PEG::Rule),
|
88
|
+
]
|
89
|
+
end
|
90
|
+
|
data/etc/ebnf.peg.sxp
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
(
|
2
|
+
(rule ebnf "1" (star _ebnf_1))
|
3
|
+
(rule _ebnf_1 "1.1" (alt declaration rule))
|
4
|
+
(rule declaration "2" (alt "@terminals" pass))
|
5
|
+
(rule rule "3" (seq LHS expression))
|
6
|
+
(rule expression "4" (seq alt))
|
7
|
+
(rule alt "5" (seq seq _alt_1))
|
8
|
+
(rule _alt_1 "5.1" (star _alt_2))
|
9
|
+
(rule _alt_2 "5.2" (seq "|" seq))
|
10
|
+
(rule seq "6" (plus diff))
|
11
|
+
(rule diff "7" (seq postfix _diff_1))
|
12
|
+
(rule _diff_1 "7.1" (opt _diff_2))
|
13
|
+
(rule _diff_2 "7.2" (seq "-" postfix))
|
14
|
+
(rule postfix "8" (seq primary _postfix_1))
|
15
|
+
(rule _postfix_1 "8.1" (opt POSTFIX))
|
16
|
+
(rule primary "9" (alt HEX SYMBOL O_RANGE RANGE STRING1 STRING2 _primary_1))
|
17
|
+
(rule _primary_1 "9.1" (seq "(" expression ")"))
|
18
|
+
(rule pass "10" (seq "@pass" expression))
|
19
|
+
(terminals _terminals (seq))
|
20
|
+
(terminal LHS "11" (seq _LHS_1 SYMBOL _LHS_2 "::="))
|
21
|
+
(terminal _LHS_1 "11.1" (opt _LHS_3))
|
22
|
+
(terminal _LHS_3 "11.3" (seq "[" SYMBOL "]" _LHS_4))
|
23
|
+
(terminal _LHS_4 "11.4" (plus " "))
|
24
|
+
(terminal _LHS_2 "11.2" (star " "))
|
25
|
+
(terminal SYMBOL "12" (plus _SYMBOL_1))
|
26
|
+
(terminal _SYMBOL_1 "12.1" (alt _SYMBOL_2 _SYMBOL_3 _SYMBOL_4 "_" "."))
|
27
|
+
(terminal _SYMBOL_2 "12.2" (range "a-z"))
|
28
|
+
(terminal _SYMBOL_3 "12.3" (range "A-Z"))
|
29
|
+
(terminal _SYMBOL_4 "12.4" (range "0-9"))
|
30
|
+
(terminal HEX "13" (seq "#x" _HEX_1))
|
31
|
+
(terminal _HEX_1 "13.1" (plus _HEX_2))
|
32
|
+
(terminal _HEX_2 "13.2" (alt _HEX_3 _HEX_4 _HEX_5))
|
33
|
+
(terminal _HEX_3 "13.3" (range "a-f"))
|
34
|
+
(terminal _HEX_4 "13.4" (range "A-F"))
|
35
|
+
(terminal _HEX_5 "13.5" (range "0-9"))
|
36
|
+
(terminal RANGE "14" (seq "[" _RANGE_1 _RANGE_2 _RANGE_3))
|
37
|
+
(terminal _RANGE_1 "14.1" (plus _RANGE_4))
|
38
|
+
(terminal _RANGE_4 "14.4" (alt _RANGE_5 _RANGE_6 R_CHAR HEX))
|
39
|
+
(terminal _RANGE_5 "14.5" (seq R_CHAR "-" R_CHAR))
|
40
|
+
(terminal _RANGE_6 "14.6" (seq HEX "-" HEX))
|
41
|
+
(terminal _RANGE_2 "14.2" (opt "-"))
|
42
|
+
(terminal _RANGE_3 "14.3" (diff "]" LHS))
|
43
|
+
(terminal O_RANGE "15" (seq "[^" _O_RANGE_1 _O_RANGE_2 "]"))
|
44
|
+
(terminal _O_RANGE_1 "15.1" (plus _O_RANGE_3))
|
45
|
+
(terminal _O_RANGE_3 "15.3" (alt _O_RANGE_4 _O_RANGE_5 R_CHAR HEX))
|
46
|
+
(terminal _O_RANGE_4 "15.4" (seq R_CHAR "-" R_CHAR))
|
47
|
+
(terminal _O_RANGE_5 "15.5" (seq HEX "-" HEX))
|
48
|
+
(terminal _O_RANGE_2 "15.2" (opt "-"))
|
49
|
+
(terminal STRING1 "16" (seq "\"" _STRING1_1 "\""))
|
50
|
+
(terminal _STRING1_1 "16.1" (star _STRING1_2))
|
51
|
+
(terminal _STRING1_2 "16.2" (diff CHAR "\""))
|
52
|
+
(terminal STRING2 "17" (seq "'" _STRING2_1 "'"))
|
53
|
+
(terminal _STRING2_1 "17.1" (star _STRING2_2))
|
54
|
+
(terminal _STRING2_2 "17.2" (diff CHAR "'"))
|
55
|
+
(terminal CHAR "18" (alt _CHAR_1 _CHAR_2 _CHAR_3 _CHAR_4))
|
56
|
+
(terminal _CHAR_1 "18.1" (range "#x9#xA#xD"))
|
57
|
+
(terminal _CHAR_2 "18.2" (range "#x20-#xD7FF"))
|
58
|
+
(terminal _CHAR_3 "18.3" (range "#xE000-#xFFFD"))
|
59
|
+
(terminal _CHAR_4 "18.4" (range "#x10000-#x10FFFF"))
|
60
|
+
(terminal R_CHAR "19" (diff CHAR _R_CHAR_1))
|
61
|
+
(terminal _R_CHAR_1 "19.1" (alt "]" "-" HEX))
|
62
|
+
(terminal POSTFIX "20" (range "?*+"))
|
63
|
+
(terminal PASS "21" (alt _PASS_1 _PASS_2 _PASS_3 _PASS_4))
|
64
|
+
(terminal _PASS_1 "21.1" (range "#x9#xA#xD#x20"))
|
65
|
+
(terminal _PASS_2 "21.2" (seq _PASS_5 _PASS_6))
|
66
|
+
(terminal _PASS_5 "21.5" (alt _PASS_7 "//"))
|
67
|
+
(terminal _PASS_7 "21.7" (diff "#" "#x"))
|
68
|
+
(terminal _PASS_6 "21.6" (star _PASS_8))
|
69
|
+
(terminal _PASS_8 "21.8" (range "^#xA#xD"))
|
70
|
+
(terminal _PASS_3 "21.3" (seq "/*" _PASS_9 "*/"))
|
71
|
+
(terminal _PASS_9 "21.9" (star _PASS_10))
|
72
|
+
(terminal _PASS_10 "21.10" (alt _PASS_11 _PASS_12))
|
73
|
+
(terminal _PASS_11 "21.11" (opt _PASS_13))
|
74
|
+
(terminal _PASS_13 "21.13" (seq "*" _PASS_14))
|
75
|
+
(terminal _PASS_14 "21.14" (range "^/"))
|
76
|
+
(terminal _PASS_12 "21.12" (range "^*"))
|
77
|
+
(terminal _PASS_4 "21.4" (seq "(*" _PASS_15 "*)"))
|
78
|
+
(terminal _PASS_15 "21.15" (star _PASS_16))
|
79
|
+
(terminal _PASS_16 "21.16" (alt _PASS_17 _PASS_18))
|
80
|
+
(terminal _PASS_17 "21.17" (opt _PASS_19))
|
81
|
+
(terminal _PASS_19 "21.19" (seq "*" _PASS_20))
|
82
|
+
(terminal _PASS_20 "21.20" (range "^)"))
|
83
|
+
(terminal _PASS_18 "21.18" (range "^*"))
|
84
|
+
(pass _pass (seq PASS)))
|
data/etc/ebnf.sxp
CHANGED
@@ -1,41 +1,40 @@
|
|
1
|
-
(
|
2
|
-
(
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
(seq "(*" (star (alt (opt (seq "*" (range "^)"))) (range "^*"))) "*)")) )) )
|
1
|
+
(
|
2
|
+
(rule ebnf "1" (star (alt declaration rule)))
|
3
|
+
(rule declaration "2" (alt "@terminals" pass))
|
4
|
+
(rule rule "3" (seq LHS expression))
|
5
|
+
(rule expression "4" (seq alt))
|
6
|
+
(rule alt "5" (seq seq (star (seq "|" seq))))
|
7
|
+
(rule seq "6" (plus diff))
|
8
|
+
(rule diff "7" (seq postfix (opt (seq "-" postfix))))
|
9
|
+
(rule postfix "8" (seq primary (opt POSTFIX)))
|
10
|
+
(rule primary "9"
|
11
|
+
(alt HEX SYMBOL O_RANGE RANGE STRING1 STRING2 (seq "(" expression ")")))
|
12
|
+
(rule pass "10" (seq "@pass" expression))
|
13
|
+
(terminals _terminals (seq))
|
14
|
+
(terminal LHS "11" (seq (opt (seq "[" SYMBOL "]" (plus " "))) SYMBOL (star " ") "::="))
|
15
|
+
(terminal SYMBOL "12" (plus (alt (range "a-z") (range "A-Z") (range "0-9") "_" ".")))
|
16
|
+
(terminal HEX "13" (seq "#x" (plus (alt (range "a-f") (range "A-F") (range "0-9")))))
|
17
|
+
(terminal RANGE "14"
|
18
|
+
(seq "["
|
19
|
+
(plus (alt (seq R_CHAR "-" R_CHAR) (seq HEX "-" HEX) R_CHAR HEX))
|
20
|
+
(opt "-")
|
21
|
+
(diff "]" LHS)) )
|
22
|
+
(terminal O_RANGE "15"
|
23
|
+
(seq "[^" (plus (alt (seq R_CHAR "-" R_CHAR) (seq HEX "-" HEX) R_CHAR HEX)) (opt "-") "]"))
|
24
|
+
(terminal STRING1 "16" (seq "\"" (star (diff CHAR "\"")) "\""))
|
25
|
+
(terminal STRING2 "17" (seq "'" (star (diff CHAR "'")) "'"))
|
26
|
+
(terminal CHAR "18"
|
27
|
+
(alt
|
28
|
+
(range "#x9#xA#xD")
|
29
|
+
(range "#x20-#xD7FF")
|
30
|
+
(range "#xE000-#xFFFD")
|
31
|
+
(range "#x10000-#x10FFFF")) )
|
32
|
+
(terminal R_CHAR "19" (diff CHAR (alt "]" "-" HEX)))
|
33
|
+
(terminal POSTFIX "20" (range "?*+"))
|
34
|
+
(terminal PASS "21"
|
35
|
+
(alt
|
36
|
+
(range "#x9#xA#xD#x20")
|
37
|
+
(seq (alt (diff "#" "#x") "//") (star (range "^#xA#xD")))
|
38
|
+
(seq "/*" (star (alt (opt (seq "*" (range "^/"))) (range "^*"))) "*/")
|
39
|
+
(seq "(*" (star (alt (opt (seq "*" (range "^)"))) (range "^*"))) "*)")) )
|
40
|
+
(pass _pass (seq PASS)))
|
data/etc/iso-ebnf.ebnf
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# W3C EBNF for ISO/IEC 14977 : 1996 EBNF
|
2
|
+
# (Scoured from https://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf)
|
3
|
+
|
4
|
+
# Extended to allow no syntax_rule to be valid.
|
5
|
+
syntax ::= syntax_rule*
|
6
|
+
|
7
|
+
syntax_rule ::= meta_identifier defining_symbol definitions_list terminator_symbol
|
8
|
+
(* A <syntax rule> defines the sequences of
|
9
|
+
symbols represented by a <meta identifier> *)
|
10
|
+
|
11
|
+
definitions_list ::= single_definition (definition_separator_symbol definitions_list)*
|
12
|
+
(* | separates alternative <single definitions> *)
|
13
|
+
|
14
|
+
single_definition ::= term (',' term)*
|
15
|
+
(* , separates successive <terms> *)
|
16
|
+
|
17
|
+
term ::= factor ('-' exception)?
|
18
|
+
(* A <term> represents any sequence of symbols that is defined by the <factor> but
|
19
|
+
not defined by the <exception> *)
|
20
|
+
|
21
|
+
exception ::= factor
|
22
|
+
(* A <factor> may be used as an <exception>
|
23
|
+
if it could be replaced by a <factor>
|
24
|
+
containingno<metaidentifiers> *)
|
25
|
+
|
26
|
+
factor ::= (integer '*')? primary
|
27
|
+
(* The <integer> specifies the number of repetitions of the <primary> *)
|
28
|
+
|
29
|
+
primary ::= optional_sequence
|
30
|
+
| repeated_sequence
|
31
|
+
| special_sequence
|
32
|
+
| grouped_sequence
|
33
|
+
| meta_identifier
|
34
|
+
| terminal_string
|
35
|
+
| empty
|
36
|
+
|
37
|
+
optional_sequence ::= start_option_symbol definitions_list end_option_symbol
|
38
|
+
(* The brackets [ and ] enclose symbols which are optional *)
|
39
|
+
|
40
|
+
repeated_sequence ::= start_repeat_symbol definitions_list end_repeat_symbol
|
41
|
+
(* The brackets { and } enclose symbols
|
42
|
+
which may be repeated any number of times *)
|
43
|
+
|
44
|
+
grouped_sequence ::= '(' definitions_list ')'
|
45
|
+
(* The brackets ( and ) allow any <definitions list> to be a <primary> *)
|
46
|
+
|
47
|
+
# Note, the following are nominally terminal rules,
|
48
|
+
# although ISO EBNF does not really distinguish between non-terminal and terminal rules.
|
49
|
+
|
50
|
+
@terminals
|
51
|
+
|
52
|
+
terminal_string ::= ("'" first_terminal_character+ "'")
|
53
|
+
| ('"' second_terminal_character+ '"')
|
54
|
+
(* A <terminal string> represents the
|
55
|
+
<characters> between the quote symbols '_' or "_" *)
|
56
|
+
|
57
|
+
meta_identifier ::= letter meta_identifier_character*
|
58
|
+
(* A <meta identifier> is the name of a syntactic element of the language being defined *)
|
59
|
+
|
60
|
+
integer ::= decimal_digit+
|
61
|
+
|
62
|
+
special_sequence ::= '?' special_sequence_character* '?'
|
63
|
+
(* The meaning of a <special sequence> is not defined in the standard metalanguage. *)
|
64
|
+
|
65
|
+
comment ::= start_comment_symbol comment_symbol* end_comment_symbol
|
66
|
+
(* A comment is allowed anywhere outside a
|
67
|
+
<terminal string>, <meta identifier>,
|
68
|
+
<integer> or <special sequence> *)
|
69
|
+
|
70
|
+
comment_symbol ::= comment | commentless_symbol | other_character
|
71
|
+
|
72
|
+
commentless_symbol ::= terminal_character | meta_identifier | integer
|
73
|
+
| terminal_string | special_sequence
|
74
|
+
|
75
|
+
letter ::= [a-zA-Z]
|
76
|
+
# gratuitous comment
|
77
|
+
decimal_digit ::= [0-9]
|
78
|
+
|
79
|
+
# Extended to allow '_'
|
80
|
+
meta_identifier_character ::= letter | decimal_digit | '_'
|
81
|
+
|
82
|
+
first_terminal_character ::= terminal_character - "'"
|
83
|
+
|
84
|
+
second_terminal_character ::= terminal_character - '"'
|
85
|
+
|
86
|
+
special_sequence_character ::= terminal_character - '?'
|
87
|
+
|
88
|
+
terminal_character ::= letter
|
89
|
+
| decimal_digit
|
90
|
+
| concatenate_symbol
|
91
|
+
| defining_symbol
|
92
|
+
| definition_separator_symbol
|
93
|
+
| end_comment_symbol
|
94
|
+
| end_group_symbol
|
95
|
+
| end_option_symbol
|
96
|
+
| end_repeat_symbol
|
97
|
+
| except_symbol
|
98
|
+
| first_quote_symbol
|
99
|
+
| repetition_symbol
|
100
|
+
| second_quote_symbol
|
101
|
+
| special_sequence_symbol
|
102
|
+
| start_comment_symbol
|
103
|
+
| start_group_symbol
|
104
|
+
| start_option_symbol
|
105
|
+
| start_repeat_symbol
|
106
|
+
| terminator_symbol
|
107
|
+
| other_character
|
108
|
+
|
109
|
+
other_character ::= [:+_%@&$<>^` ̃#x20#x23] | '\'
|
110
|
+
|
111
|
+
gap_separator ::= [#x9#xa#xb#xc#xd#x20]
|
112
|
+
|
113
|
+
@pass gap_separator+ | comment
|
114
|
+
|
115
|
+
empty ::= ''
|
116
|
+
|
117
|
+
concatenate_symbol ::= ','
|
118
|
+
repetition_symbol ::= '*'
|
119
|
+
except_symbol ::= '-'
|
120
|
+
first_quote_symbol ::= "'"
|
121
|
+
second_quote_symbol ::= '"'
|
122
|
+
start_comment_symbol ::= '(*'
|
123
|
+
end_comment_symbol ::= '*)'
|
124
|
+
start_group_symbol ::= '('
|
125
|
+
end_group_symbol ::= ')'
|
126
|
+
special_sequence_symbol ::= '?'
|
127
|
+
|
128
|
+
# Simple terminals that are often extended
|
129
|
+
defining_symbol ::= '=' | ':'
|
130
|
+
definition_separator_symbol ::= '|' | '/' | '!'
|
131
|
+
terminator_symbol ::= ';' | '.'
|
132
|
+
start_option_symbol ::= '['
|
133
|
+
end_option_symbol ::= ']'
|
134
|
+
start_repeat_symbol ::= '{' | '(:'
|
135
|
+
end_repeat_symbol ::= '}' | ':)'
|
136
|
+
|
137
|
+
# Symbols described, but not actually used.
|
138
|
+
|
139
|
+
gap_free_symbol ::= (terminal_character - ['"])
|
140
|
+
| terminal_string
|
@@ -0,0 +1,138 @@
|
|
1
|
+
(* W3C EBNF for ISO/IEC 14977 : 1996 EBNF *)
|
2
|
+
(* Scoured from https://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf *)
|
3
|
+
|
4
|
+
syntax = syntax_rule, {syntax_rule} ;
|
5
|
+
|
6
|
+
syntax_rule = meta_identifier, defining_symbol, definitions_list, terminator_symbol
|
7
|
+
(* A <syntax rule> defines the sequences of
|
8
|
+
symbols represented by a <meta identifier> *);
|
9
|
+
|
10
|
+
definitions_list = single_definition, {definition_separator_symbol, definitions_list}
|
11
|
+
(* | separates alternative <single definitions> *);
|
12
|
+
|
13
|
+
single_definition = term, {',', term}
|
14
|
+
(* , separates successive <terms> *);
|
15
|
+
|
16
|
+
term = factor, ['-', exception]
|
17
|
+
(* A <term> represents any sequence of symbols that is defined by the <factor> but
|
18
|
+
not defined by the <exception> *);
|
19
|
+
|
20
|
+
exception = factor
|
21
|
+
(* A <factor> may be used as an <exception>
|
22
|
+
if it could be replaced by a <factor>
|
23
|
+
containingno<metaidentifiers> *);
|
24
|
+
|
25
|
+
factor = [integer, '*'], primary
|
26
|
+
(* The <integer> specifies the number of repetitions of the <primary> *);
|
27
|
+
|
28
|
+
primary = optional_sequence
|
29
|
+
| repeated_sequence
|
30
|
+
| special_sequence
|
31
|
+
| grouped_sequence
|
32
|
+
| meta_identifier
|
33
|
+
| terminal_string
|
34
|
+
| empty
|
35
|
+
;
|
36
|
+
|
37
|
+
optional_sequence = start_option_symbol, definitions_list, end_option_symbol
|
38
|
+
(* The brackets [ and ] enclose symbols which are optional *);
|
39
|
+
|
40
|
+
repeated_sequence = start_repeat_symbol, definitions_list, end_repeat_symbol
|
41
|
+
(* The brackets { and } enclose symbols
|
42
|
+
which may be repeated any number of times *);
|
43
|
+
|
44
|
+
grouped_sequence = '(', definitions_list, ')'
|
45
|
+
(* The brackets ( and ) allow any <definitions list> to be a <primary> *);
|
46
|
+
|
47
|
+
terminal_string = ("'", first_terminal_character, {first_terminal_character}, "'")
|
48
|
+
| ('"', second_terminal_character, {second_terminal_character}, '"')
|
49
|
+
(* A <terminal string> represents the
|
50
|
+
<characters> between the quote symbols '_' or "_" *);
|
51
|
+
|
52
|
+
meta_identifier = letter, {meta_identifier_character}
|
53
|
+
(* A <meta identifier> is the name of a syntactic element of the language being defined *);
|
54
|
+
|
55
|
+
integer = decimal_digit, {decimal_digit} ;
|
56
|
+
|
57
|
+
special_sequence = '?', {special_sequence_character}, '?'
|
58
|
+
(* The meaning of a <special sequence> is not defined in the standard metalanguage. *);
|
59
|
+
|
60
|
+
comment = '(*', {comment_symbol}, '*)'
|
61
|
+
(* A comment is allowed anywhere outside a
|
62
|
+
<terminal string>, <meta identifier>,
|
63
|
+
<integer> or <special sequence> *);
|
64
|
+
|
65
|
+
comment_symbol = comment | commentless_symbol | other_character ;
|
66
|
+
|
67
|
+
commentless_symbol = terminal_character | meta_identifier | integer
|
68
|
+
| terminal_string | special_sequence
|
69
|
+
;
|
70
|
+
|
71
|
+
letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
|
72
|
+
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
|
73
|
+
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
|
74
|
+
| "V" | "W" | "X" | "Y" | "Z" | "a" | "b"
|
75
|
+
| "c" | "d" | "e" | "f" | "g" | "h" | "i"
|
76
|
+
| "j" | "k" | "l" | "m" | "n" | "o" | "p"
|
77
|
+
| "q" | "r" | "s" | "t" | "u" | "v" | "w"
|
78
|
+
| "x" | "y" | "z"
|
79
|
+
;
|
80
|
+
|
81
|
+
decimal_digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
|
82
|
+
|
83
|
+
(* Extended to allow '_' *)
|
84
|
+
meta_identifier_character = letter | decimal_digit | '_' ;
|
85
|
+
|
86
|
+
first_terminal_character = terminal_character - "'" ;
|
87
|
+
|
88
|
+
second_terminal_character = terminal_character - '"' ;
|
89
|
+
|
90
|
+
special_sequence_character = terminal_character - '?' ;
|
91
|
+
|
92
|
+
terminal_character = letter
|
93
|
+
| decimal_digit
|
94
|
+
| concatenate_symbol
|
95
|
+
| defining_symbol
|
96
|
+
| definition_separator_symbol
|
97
|
+
| end_comment_symbol
|
98
|
+
| end_group_symbol
|
99
|
+
| end_option_symbol
|
100
|
+
| end_repeat_symbol
|
101
|
+
| except_symbol
|
102
|
+
| first_quote_symbol
|
103
|
+
| repetition_symbol
|
104
|
+
| second_quote_symbol
|
105
|
+
| special_sequence_symbol
|
106
|
+
| start_comment_symbol
|
107
|
+
| start_group_symbol
|
108
|
+
| start_option_symbol
|
109
|
+
| start_repeat_symbol
|
110
|
+
| terminator_symbol
|
111
|
+
| other_character
|
112
|
+
;
|
113
|
+
|
114
|
+
other_character = ' ' | ':' | '+' | '_' | '%' | '@' | '&'
|
115
|
+
| '#' | '$' | '<' | '>' | '\' | '^' | '`'
|
116
|
+
| '~' ;
|
117
|
+
|
118
|
+
empty = ;
|
119
|
+
|
120
|
+
concatenate_symbol = ',' ;
|
121
|
+
repetition_symbol = '*' ;
|
122
|
+
except_symbol = '-' ;
|
123
|
+
first_quote_symbol = "'" ;
|
124
|
+
second_quote_symbol = '"' ;
|
125
|
+
start_comment_symbol = '(*' ;
|
126
|
+
end_comment_symbol = '*)' ;
|
127
|
+
start_group_symbol = '(' ;
|
128
|
+
end_group_symbol = ')' ;
|
129
|
+
special_sequence_symbol = '?' ;
|
130
|
+
|
131
|
+
(* Simple terminals that are often extended *)
|
132
|
+
defining_symbol = '=' | ':' ;
|
133
|
+
definition_separator_symbol = '|' | '/' | '!' ;
|
134
|
+
terminator_symbol = ';' | '.' ;
|
135
|
+
start_option_symbol = '[' ;
|
136
|
+
end_option_symbol = ']' ;
|
137
|
+
start_repeat_symbol = '{' | '(:' ;
|
138
|
+
end_repeat_symbol = '}' | ':)' ;
|