erl_comment_scan(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

🌸 NAME 🌸

erl_comment_scan β€” bestie, this is the module that reads comment lines out of Erlang source code. That's it. That's the whole vibe. She looks at your %-started little thoughts and hands them back to you as tidy data. Obsessed. πŸ’–


✨ DESCRIPTION ✨

(ngl the original page doesn't say anything here, so we're just gonna move on β€” the real tea is in DATA TYPES and FUNCTIONS 🫢)


πŸŽ€ DATA TYPES πŸŽ€

  • comment() β€” a whole multi-line comment, packaged up like this:
{Line :: integer(),
 Column :: integer(),
 Indentation :: integer(),
 Text :: [string()]}.
  • commentLine() β€” a single lonely comment line, looking like this:
{Line :: integer(),
 Column :: integer(),
 Indent :: integer(),
 Text :: string()}.

πŸ”₯ FUNCTIONS πŸ”₯

file(file:filename()) -> [comment()].

Extracts comments from an Erlang source code file. ✨

She gives you back a list of entries, each one representing a multi-line comment, and they're listed in order of increasing line-numbers (so top of the file first, like a normal person reads πŸ“–).

For each entry:

  • Text is a list of strings representing the consecutive comment lines in top-down order. Those strings contain all characters following (but not including) the first comment-introducing % character on the line, and they stop up to (but not including) the line-terminating newline. Like, the % and the newline are NOT invited to the party πŸ™ˆ
  • Line is the line number, and Column is the left column of the comment β€” aka the column of the comment-introducing % character. iykyk πŸ’…
  • Indent is the indentation (or padding), measured in character positions between the last non-whitespace character before the comment (or the left margin, if there's nothing before it) and the left column of the comment.

Line and Column are always positive integers, and Indentation is a nonnegative integer. No cap. 🧚

⚠️ Heads up bestie: evaluation exits with reason {read, Reason} if a read error happened, where Reason is an atom corresponding to a Posix error code. Go check the module //kernel/file for the deets. πŸ’€

join_lines([commentLine()]) -> [comment()].

Joins individual comment lines into multi-line comments. She's literally a matchmaker 🫢

The signature, verbatim, for the record:

join_lines(CommentLines) ->

The input is a list of entries representing individual comment lines, in order of decreasing line-numbers β€” peep scan_lines/1 for the full rundown. πŸ‘€

The result is a list of entries representing multi-line comments, still listed in order of decreasing line-numbers, BUT β€” and this is the glow-up β€” for each entry, Text is a list of consecutive comment lines in order of increasing line-numbers (that's top-down, babes, the correct direction 🌈).

See also: scan_lines/1.


scan_lines(string()) -> [commentLine()].

Extracts individual comment lines from a source code string. ⭐

She hands back a list of comment lines found in the text, listed in order of decreasing line-numbers β€” which means the last comment line in the input is first in the resulting list. Yes bestie, it's backwards on purpose, that's just her era. πŸ’…

Text is a single string containing all characters following (but not including) the first comment-introducing % character on the line, up to (but not including) the line-terminating newline.

For the details on Line, Column and Indent, go see file/1. πŸŽ€


string(string()) -> [comment()].

Extracts comments from a string containing Erlang source code. 🌸

Except for the whole "reading directly from a string" thing, the behavior is exactly the same as file/1. Same energy, different input. Periodt. πŸ‘‘

See also: file/1.


<div align="center">πŸ’– ✨ πŸ’… ✨ πŸ’–</div>

okay and that's the whole page bestie!! this came to you from Ericsson AB as part of syntax_tools 4.1, and it lives at manual page erl_comment_scan(3). go read some comments, slay, and hydrate πŸ’œπŸ¦‹

πŸ“¦ where this page comes from