From b15d48228ef03f7ed96b44578bee8ae66c0e2939 Mon Sep 17 00:00:00 2001 From: mgcaret Date: Wed, 21 Oct 2020 23:24:29 -0700 Subject: [PATCH] update utils to support indexing of headerless words --- utils/covrep.rb | 6 ++++-- utils/fs2asm.rb | 13 ++++++++++++- utils/index.rb | 12 ++++++------ utils/index2md.rb | 4 +++- 4 files changed, 25 insertions(+), 10 deletions(-) mode change 100644 => 100755 utils/fs2asm.rb diff --git a/utils/covrep.rb b/utils/covrep.rb index 8a507dd..58e8586 100755 --- a/utils/covrep.rb +++ b/utils/covrep.rb @@ -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 diff --git a/utils/fs2asm.rb b/utils/fs2asm.rb old mode 100644 new mode 100755 index 9a91284..6c98073 --- a/utils/fs2asm.rb +++ b/utils/fs2asm.rb @@ -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), diff --git a/utils/index.rb b/utils/index.rb index 077f689..e59e6cc 100755 --- a/utils/index.rb +++ b/utils/index.rb @@ -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/ diff --git a/utils/index2md.rb b/utils/index2md.rb index 6ecdfab..1a97cb5 100755 --- a/utils/index2md.rb +++ b/utils/index2md.rb @@ -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}"