|
|
|
@ -101,7 +101,7 @@ class Specs
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def parse_list(header : String, content : Array(String))
|
|
|
|
|
name = /[a-zA-Z][a-zA-Z0-9]*/.match(header).try &.[0]
|
|
|
|
|
name = /[a-zA-Z][a-zA-Z0-9-_]*/.match(header).try &.[0]
|
|
|
|
|
# puts "new list: #{name}"
|
|
|
|
|
|
|
|
|
|
list = Array(String).new
|
|
|
|
@ -130,7 +130,7 @@ class Specs
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def parse_code_block(header : String, content : Array(String))
|
|
|
|
|
name = /[a-zA-Z][a-zA-Z0-9]*/.match(header).try &.[0]
|
|
|
|
|
name = /[a-zA-Z][a-zA-Z0-9-_]*/.match(header).try &.[0]
|
|
|
|
|
# puts "new code block: #{name}"
|
|
|
|
|
|
|
|
|
|
value = String.build do |str|
|
|
|
|
@ -159,7 +159,7 @@ class Specs
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def parse_section(header : String, content : Array(String))
|
|
|
|
|
results = /^[%]([a-zA-Z][a-zA-Z0-9]*)[ \t]*([^#]*)/.match(header)
|
|
|
|
|
results = /^[%]([a-zA-Z][a-zA-Z0-9-_]*)[ \t]*([^#]*)/.match(header)
|
|
|
|
|
name = results[1]? if results
|
|
|
|
|
options = results[2]? if results
|
|
|
|
|
|
|
|
|
@ -241,31 +241,23 @@ class Specs
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def parse_lines(content : Array(String))
|
|
|
|
|
count = 0
|
|
|
|
|
|
|
|
|
|
while line = content.shift?
|
|
|
|
|
case line
|
|
|
|
|
when /^[ \t]*$/
|
|
|
|
|
else
|
|
|
|
|
# puts "line #{count}: #{line}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
case line
|
|
|
|
|
when /^[a-zA-Z][a-zA-Z0-9]*:[ \t]*([#].*)?$/
|
|
|
|
|
when /^[a-zA-Z][a-zA-Z0-9-_]*:[ \t]*([#].*)?$/
|
|
|
|
|
parse_list line, content
|
|
|
|
|
when /^[a-zA-Z][a-zA-Z]*:[ \t]+[^#]+/
|
|
|
|
|
when /^[a-zA-Z][a-zA-Z0-9-_]*:[ \t]+[^#]+/
|
|
|
|
|
parse_assignment line
|
|
|
|
|
when /^[@][a-zA-Z][a-zA-Z]*[ \t]*([#].*)?/
|
|
|
|
|
when /^[@][a-zA-Z][a-zA-Z0-9-_]*[ \t]*([#].*)?/
|
|
|
|
|
parse_code_block line, content
|
|
|
|
|
when /^[%][a-zA-Z][a-zA-Z]*[ \t]*([#].*)?/
|
|
|
|
|
when /^[%][a-zA-Z][a-zA-Z0-9-_]*[ \t]*([#].*)?/
|
|
|
|
|
parse_section line, content
|
|
|
|
|
when /^[ \t]*#/
|
|
|
|
|
# puts "comment"
|
|
|
|
|
when /^[ \t]+/
|
|
|
|
|
puts "tab!! should not happen"
|
|
|
|
|
when /^[ \t]+$/
|
|
|
|
|
# puts "empty line"
|
|
|
|
|
when /^[ \t]+[^ \t#]/
|
|
|
|
|
raise "line starting with spaces or a tabulation outside a list or a section: should not happen"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
count += 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|