authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-23 20:40:09-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-23 20:40:09-04:00
log2952604d5d18078ed768e12010f4463176620e9a
tree9738d3102ba1c1324ea16793de0c3b6a7ccd4c84
parentc432811d96de1e8ac019ce16457c3992f039cb8c

update docgen to new ast API


1 files changed, 18 insertions(+), 18 deletions(-)

doc/docgen.zig+18-18
......@@ -776,7 +776,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
776776 next_tok_is_fn = false;
777777
778778 const token = tokenizer.next();
779 try writeEscaped(out, src[index..token.start]);
779 try writeEscaped(out, src[index..token.loc.start]);
780780 switch (token.id) {
781781 .Eof => break,
782782
......@@ -827,13 +827,13 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
827827 .Keyword_while,
828828 => {
829829 try out.writeAll("<span class=\"tok-kw\">");
830 try writeEscaped(out, src[token.start..token.end]);
830 try writeEscaped(out, src[token.loc.start..token.loc.end]);
831831 try out.writeAll("</span>");
832832 },
833833
834834 .Keyword_fn => {
835835 try out.writeAll("<span class=\"tok-kw\">");
836 try writeEscaped(out, src[token.start..token.end]);
836 try writeEscaped(out, src[token.loc.start..token.loc.end]);
837837 try out.writeAll("</span>");
838838 next_tok_is_fn = true;
839839 },
......@@ -844,7 +844,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
844844 .Keyword_false,
845845 => {
846846 try out.writeAll("<span class=\"tok-null\">");
847 try writeEscaped(out, src[token.start..token.end]);
847 try writeEscaped(out, src[token.loc.start..token.loc.end]);
848848 try out.writeAll("</span>");
849849 },
850850
......@@ -853,13 +853,13 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
853853 .CharLiteral,
854854 => {
855855 try out.writeAll("<span class=\"tok-str\">");
856 try writeEscaped(out, src[token.start..token.end]);
856 try writeEscaped(out, src[token.loc.start..token.loc.end]);
857857 try out.writeAll("</span>");
858858 },
859859
860860 .Builtin => {
861861 try out.writeAll("<span class=\"tok-builtin\">");
862 try writeEscaped(out, src[token.start..token.end]);
862 try writeEscaped(out, src[token.loc.start..token.loc.end]);
863863 try out.writeAll("</span>");
864864 },
865865
......@@ -869,34 +869,34 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
869869 .ShebangLine,
870870 => {
871871 try out.writeAll("<span class=\"tok-comment\">");
872 try writeEscaped(out, src[token.start..token.end]);
872 try writeEscaped(out, src[token.loc.start..token.loc.end]);
873873 try out.writeAll("</span>");
874874 },
875875
876876 .Identifier => {
877877 if (prev_tok_was_fn) {
878878 try out.writeAll("<span class=\"tok-fn\">");
879 try writeEscaped(out, src[token.start..token.end]);
879 try writeEscaped(out, src[token.loc.start..token.loc.end]);
880880 try out.writeAll("</span>");
881881 } else {
882882 const is_int = blk: {
883 if (src[token.start] != 'i' and src[token.start] != 'u')
883 if (src[token.loc.start] != 'i' and src[token.loc.start] != 'u')
884884 break :blk false;
885 var i = token.start + 1;
886 if (i == token.end)
885 var i = token.loc.start + 1;
886 if (i == token.loc.end)
887887 break :blk false;
888 while (i != token.end) : (i += 1) {
888 while (i != token.loc.end) : (i += 1) {
889889 if (src[i] < '0' or src[i] > '9')
890890 break :blk false;
891891 }
892892 break :blk true;
893893 };
894 if (is_int or isType(src[token.start..token.end])) {
894 if (is_int or isType(src[token.loc.start..token.loc.end])) {
895895 try out.writeAll("<span class=\"tok-type\">");
896 try writeEscaped(out, src[token.start..token.end]);
896 try writeEscaped(out, src[token.loc.start..token.loc.end]);
897897 try out.writeAll("</span>");
898898 } else {
899 try writeEscaped(out, src[token.start..token.end]);
899 try writeEscaped(out, src[token.loc.start..token.loc.end]);
900900 }
901901 }
902902 },
......@@ -905,7 +905,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
905905 .FloatLiteral,
906906 => {
907907 try out.writeAll("<span class=\"tok-number\">");
908 try writeEscaped(out, src[token.start..token.end]);
908 try writeEscaped(out, src[token.loc.start..token.loc.end]);
909909 try out.writeAll("</span>");
910910 },
911911
......@@ -963,7 +963,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
963963 .AngleBracketAngleBracketRight,
964964 .AngleBracketAngleBracketRightEqual,
965965 .Tilde,
966 => try writeEscaped(out, src[token.start..token.end]),
966 => try writeEscaped(out, src[token.loc.start..token.loc.end]),
967967
968968 .Invalid, .Invalid_ampersands => return parseError(
969969 docgen_tokenizer,
......@@ -972,7 +972,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
972972 .{},
973973 ),
974974 }
975 index = token.end;
975 index = token.loc.end;
976976 }
977977 try out.writeAll("</code>");
978978}