update utils to support indexing of headerless words

This commit is contained in:
mgcaret 2020-10-21 23:24:29 -07:00
parent 5433d59009
commit b15d48228e
4 changed files with 25 additions and 10 deletions

View File

@ -6,8 +6,9 @@ def usage
Usage: #{$0} index-file|-
Reads index file (- for stdin) and produces a test coverage
report. The index file must have been merged with test
coverage data or all words will be reporteed as uncovered.
report for non-headerless words. The index file must have
been merged with test coverage data or all words will be
reported as uncovered.
EOF
exit 1
end
@ -25,6 +26,7 @@ covered = []
uncovered = []
index.each_pair do |name, props|
next if props['headerless']
if props["tests"] && props["tests"] > 0
covered << name
else

13
utils/fs2asm.rb Normal file → Executable file
View File

@ -55,7 +55,9 @@
#
# Words may be changed to headerless and back to normal with HEADERS and HEADERLESS.
# Unsupported features:
# Unsupported items:
#
# Setting flags on words.
#
# RECURSE $HEX( TO and END-CODE
# quotations: [: and ;]
@ -476,6 +478,14 @@ def f_literal
emit_line('', 'ONLIT', @stack.pop)
end
def f_2literal
abort('LITERAL outside of definition') unless @in_colon
n2 = @stack.pop
n1 = @stack.pop
emit_line('', 'ONLIT', n1)
emit_line('', 'ONLIT', n2)
end
def f_postpone
abort('POSTPONE outside of definition') unless @in_colon
w = parse_word.upcase
@ -600,6 +610,7 @@ end
'CONTROL' => method(:f_control),
'[COMPILE]' => method(:f_ccompile),
'LITERAL' => method(:f_literal),
'2LITERAL' => method(:f_2literal),
'POSTPONE' => method(:f_postpone),
'COMPILE' => method(:f_compile),
'H#' => method(:f_hnum),

View File

@ -34,15 +34,15 @@ input.lines.each do |line|
# nothing
when /^\s*;\s+H:\s*(.+)/
help << $1
when /^\s*dword(q?)\s+(.+)/
label, name, flags = CSV.parse_line($2)
when /^\s*([dh])word(q?)\s+(.+)/
label, name, flags = CSV.parse_line($3)
name.upcase!
name.tr!("'", '"') if $1 == 'q'
output[name] ||= {"label" => label}
output[name].merge!({"help" => help}) unless help.empty?
name.tr!("'", '"') if $2 == 'q'
output[name] ||= {'label' => label, 'headerless' => ($1 == 'h')}
output[name].merge!({'help' => help}) unless help.empty?
if flags
fl = flags.split(/[|\+]/)
output[name].merge!({"flags" => fl}) unless fl.empty?
output[name].merge!({'flags' => fl}) unless fl.empty?
end
output[name].merge!({"tests" => coverage[name.downcase]}) if coverage[name.downcase]
when /^\s*eword/

View File

@ -7,7 +7,8 @@ def usage
Usage: #{$0} index-file|- [dictionary-title]
reads index file (- for stdin) and produces markdown-
formatted output for documentation purposes.
formatted output documenting non-headerless words for the
indexed dictionary.
if dictionary-title is specified, it is used as the top
level heading instead of the file name.
@ -33,6 +34,7 @@ puts
index.keys.sort.each do |word|
word_info = index[word]
next if word_info['headerless']
cword = word.gsub(/^(#+)$/) { "\\#{$1}" } # let '#' display properly
cword.gsub!(/^([<>])/) { "\\#{$1}" }
puts "## #{cword}"