Created
February 19, 2013 09:03
-
-
Save sp3c73r2038/4984204 to your computer and use it in GitHub Desktop.
Augmented BNF for Syntax Specifications example in ruby.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding:utf-8 -*- | |
# some syntax define in RFC | |
# refer to http://tools.ietf.org/html/rfc5234 | |
def loop_print(range) | |
if range.is_a? Range | |
range.each do |v| | |
print v, ":", v.to_s.to_i.chr, "\n" | |
end | |
else | |
v = range | |
print v, ":", v.to_s.to_i.chr, "\n" | |
end | |
end | |
# VSCHAR | |
puts "=========== VSCHAR ==========" | |
loop_print((0x20..0x7E)) | |
# NQCHAR | |
puts "=========== NQCHAR ==========" | |
[(0x21), (0x23..0x5B), (0x5D..0x7E)].each do |range| | |
loop_print(range) | |
end | |
# NQSCHAR | |
puts "=========== NQSCHAR ==========" | |
[(0x20), (0x23..0x5B), (0x5D..0x7E)].each do |range| | |
loop_print(range) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment