more mass renaming
This commit is contained in:
@@ -0,0 +1,199 @@
|
||||
% ANSI screen drawing macros in erlang
|
||||
%
|
||||
% Author: Peter Harpending <peterharpending@qpq.swiss>
|
||||
% Date: 2026-04-10
|
||||
%
|
||||
% Copyright (C) 2026, QPQ AG
|
||||
|
||||
% Not exhaustive, just what I need for the moment
|
||||
% ref: https://gist.github.com/ConnerWill/d4b6c776b509add763e17f9f113fd25b
|
||||
-define(ANSI_ESC, [27]).
|
||||
-define(ANSI_CRLF, "\r\n").
|
||||
-define(ANSI_FF, [12]).
|
||||
-define(ANSI_CLEAR, [12]).
|
||||
|
||||
-define(ANSI_LINE(X), [X, ?ANSI_CRLF]).
|
||||
|
||||
% MARKDOWN TIER TEXT FORMATTING
|
||||
|
||||
% resets all formatting
|
||||
-define(ANSI_RESET, [?ANSI_ESC, "[0m"]).
|
||||
|
||||
-define(ANSI_BOLD, [?ANSI_ESC, "[1m"]).
|
||||
-define(ANSI_DIM, [?ANSI_ESC, "[2m"]).
|
||||
-define(ANSI_ITALIC, [?ANSI_ESC, "[3m"]).
|
||||
-define(ANSI_ULINE, [?ANSI_ESC, "[4m"]).
|
||||
-define(ANSI_BLINK, [?ANSI_ESC, "[5m"]).
|
||||
-define(ANSI_INVERT, [?ANSI_ESC, "[7m"]).
|
||||
-define(ANSI_INVIS, [?ANSI_ESC, "[8m"]).
|
||||
-define(ANSI_STRIKE, [?ANSI_ESC, "[9m"]).
|
||||
|
||||
% > Note: Both dim and bold modes are reset with the ESC[22m sequence. The
|
||||
% > ESC[21m sequence is a non-specified sequence for double underline mode and
|
||||
% > only work in some terminals and is reset with ESC[24m.
|
||||
-define(ANSI_UNBOLD, [?ANSI_ESC, "[22m"]).
|
||||
-define(ANSI_UNDIM, [?ANSI_ESC, "[22m"]).
|
||||
-define(ANSI_UNITALIC, [?ANSI_ESC, "[23m"]).
|
||||
-define(ANSI_UNULINE, [?ANSI_ESC, "[24m"]).
|
||||
-define(ANSI_UNBLINK, [?ANSI_ESC, "[25m"]).
|
||||
-define(ANSI_UNINVERT, [?ANSI_ESC, "[27m"]).
|
||||
-define(ANSI_UNINVIS, [?ANSI_ESC, "[28m"]).
|
||||
-define(ANSI_UNSTRIKE, [?ANSI_ESC, "[29m"]).
|
||||
|
||||
-define(ANSI_BOLD(X), [?ANSI_BOLD, X, ?ANSI_UNBOLD]).
|
||||
-define(ANSI_DIM(X), [?ANSI_DIM, X, ?ANSI_UNDIM]).
|
||||
-define(ANSI_ITALIC(X), [?ANSI_ITALIC, X, ?ANSI_UNITALIC]).
|
||||
-define(ANSI_ULINE(X), [?ANSI_ULINE, X, ?ANSI_UNULINE]).
|
||||
-define(ANSI_BLINK(X), [?ANSI_BLINK, X, ?ANSI_UNBLINK]).
|
||||
-define(ANSI_INVERT(X), [?ANSI_INVERT, X, ?ANSI_UNINVERT]).
|
||||
-define(ANSI_INVIS(X), [?ANSI_INVIS, X, ?ANSI_UNINVIS]).
|
||||
-define(ANSI_STRIKE(X), [?ANSI_STRIKE, X, ?ANSI_UNSTRIKE]).
|
||||
|
||||
|
||||
% COLORS
|
||||
%
|
||||
% COLOR SetFG SetBG
|
||||
% -----------------------------
|
||||
% Black 30 40
|
||||
% Red 31 41
|
||||
% Green 32 42
|
||||
% Yellow 33 43
|
||||
% Blue 34 44
|
||||
% Magenta 35 45
|
||||
% Cyan 36 46
|
||||
% White 37 47
|
||||
% Default 39 49
|
||||
|
||||
-define(ANSI_FG_RESET, [?ANSI_ESC, "[39m"]).
|
||||
-define(ANSI_BG_RESET, [?ANSI_ESC, "[49m"]).
|
||||
|
||||
-define(ANSI_FG_BLACK, [?ANSI_ESC, "[30m"]).
|
||||
-define(ANSI_FG_RED, [?ANSI_ESC, "[31m"]).
|
||||
-define(ANSI_FG_GREEN, [?ANSI_ESC, "[32m"]).
|
||||
-define(ANSI_FG_YELLOW, [?ANSI_ESC, "[33m"]).
|
||||
-define(ANSI_FG_BLUE, [?ANSI_ESC, "[34m"]).
|
||||
-define(ANSI_FG_MAGENTA, [?ANSI_ESC, "[35m"]).
|
||||
-define(ANSI_FG_CYAN, [?ANSI_ESC, "[36m"]).
|
||||
-define(ANSI_FG_WHITE, [?ANSI_ESC, "[37m"]).
|
||||
|
||||
-define(ANSI_BG_BLACK, [?ANSI_ESC, "[40m"]).
|
||||
-define(ANSI_BG_RED, [?ANSI_ESC, "[41m"]).
|
||||
-define(ANSI_BG_GREEN, [?ANSI_ESC, "[42m"]).
|
||||
-define(ANSI_BG_YELLOW, [?ANSI_ESC, "[43m"]).
|
||||
-define(ANSI_BG_BLUE, [?ANSI_ESC, "[44m"]).
|
||||
-define(ANSI_BG_MAGENTA, [?ANSI_ESC, "[45m"]).
|
||||
-define(ANSI_BG_CYAN, [?ANSI_ESC, "[46m"]).
|
||||
-define(ANSI_BG_WHITE, [?ANSI_ESC, "[47m"]).
|
||||
|
||||
|
||||
-define(ANSI_FG_BLACK(X), [?ANSI_FG_BLACK, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_RED(X), [?ANSI_FG_RED, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_GREEN(X), [?ANSI_FG_GREEN, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_YELLOW(X), [?ANSI_FG_YELLOW, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_BLUE(X), [?ANSI_FG_BLUE, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_MAGENTA(X), [?ANSI_FG_MAGENTA, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_CYAN(X), [?ANSI_FG_CYAN, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_WHITE(X), [?ANSI_FG_WHITE, X, ?ANSI_FG_RESET]).
|
||||
|
||||
-define(ANSI_BG_BLACK(X), [?ANSI_BG_BLACK, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_RED(X), [?ANSI_BG_RED, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_GREEN(X), [?ANSI_BG_GREEN, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_YELLOW(X), [?ANSI_BG_YELLOW, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_BLUE(X), [?ANSI_BG_BLUE, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_MAGENTA(X), [?ANSI_BG_MAGENTA, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_CYAN(X), [?ANSI_BG_CYAN, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_WHITE(X), [?ANSI_BG_WHITE, X, ?ANSI_BG_RESET]).
|
||||
|
||||
% bright colors
|
||||
-define(ANSI_FG_BBLACK, [?ANSI_ESC, "[90m"]).
|
||||
-define(ANSI_FG_BRED, [?ANSI_ESC, "[91m"]).
|
||||
-define(ANSI_FG_BGREEN, [?ANSI_ESC, "[92m"]).
|
||||
-define(ANSI_FG_BYELLOW, [?ANSI_ESC, "[93m"]).
|
||||
-define(ANSI_FG_BBLUE, [?ANSI_ESC, "[94m"]).
|
||||
-define(ANSI_FG_BMAGENTA, [?ANSI_ESC, "[95m"]).
|
||||
-define(ANSI_FG_BCYAN, [?ANSI_ESC, "[96m"]).
|
||||
-define(ANSI_FG_BWHITE, [?ANSI_ESC, "[97m"]).
|
||||
|
||||
-define(ANSI_BG_BBLACK, [?ANSI_ESC, "[100m"]).
|
||||
-define(ANSI_BG_BRED, [?ANSI_ESC, "[101m"]).
|
||||
-define(ANSI_BG_BGREEN, [?ANSI_ESC, "[102m"]).
|
||||
-define(ANSI_BG_BYELLOW, [?ANSI_ESC, "[103m"]).
|
||||
-define(ANSI_BG_BBLUE, [?ANSI_ESC, "[104m"]).
|
||||
-define(ANSI_BG_BMAGENTA, [?ANSI_ESC, "[105m"]).
|
||||
-define(ANSI_BG_BCYAN, [?ANSI_ESC, "[106m"]).
|
||||
-define(ANSI_BG_BWHITE, [?ANSI_ESC, "[107m"]).
|
||||
|
||||
-define(ANSI_FG_BBLACK(X), [?ANSI_FG_BBLACK, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_BRED(X), [?ANSI_FG_BRED, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_BGREEN(X), [?ANSI_FG_BGREEN, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_BYELLOW(X), [?ANSI_FG_BYELLOW, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_BBLUE(X), [?ANSI_FG_BBLUE, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_BMAGENTA(X), [?ANSI_FG_BMAGENTA, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_BCYAN(X), [?ANSI_FG_BCYAN, X, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_FG_BWHITE(X), [?ANSI_FG_BWHITE, X, ?ANSI_FG_RESET]).
|
||||
|
||||
-define(ANSI_BG_BBLACK(X), [?ANSI_BG_BBLACK, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_BRED(X), [?ANSI_BG_BRED, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_BGREEN(X), [?ANSI_BG_BGREEN, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_BYELLOW(X), [?ANSI_BG_BYELLOW, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_BBLUE(X), [?ANSI_BG_BBLUE, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_BMAGENTA(X), [?ANSI_BG_BMAGENTA, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_BCYAN(X), [?ANSI_BG_BCYAN, X, ?ANSI_BG_RESET]).
|
||||
-define(ANSI_BG_BWHITE(X), [?ANSI_BG_BWHITE, X, ?ANSI_BG_RESET]).
|
||||
|
||||
-define(ANSI_FG_RGB(R,G,B),
|
||||
[?ANSI_ESC,
|
||||
"[38;2;",
|
||||
integer_to_list(R),";",
|
||||
integer_to_list(G),";",
|
||||
integer_to_list(B),"m"]
|
||||
).
|
||||
-define(ANSI_BG_RGB(R,G,B),
|
||||
[?ANSI_ESC,
|
||||
"[48;2;",
|
||||
integer_to_list(R),";",
|
||||
integer_to_list(G),";",
|
||||
integer_to_list(B),"m"]
|
||||
).
|
||||
|
||||
-define(ANSI_FG_RGB(R,G,B,Chars), [?ANSI_FG_RGB(R,G,B), Chars, ?ANSI_FG_RESET]).
|
||||
-define(ANSI_BG_RGB(R,G,B,Chars), [?ANSI_BG_RGB(R,G,B), Chars, ?ANSI_BG_RESET]).
|
||||
|
||||
|
||||
% cursor controls
|
||||
-define(ANSI_CUR_HOME, [?ANSI_ESC, "[H"]).
|
||||
|
||||
-define(ANSI_CUR_XY(X, Y), [?ANSI_ESC, "[", integer_to_list(Y), ";", integer_to_list(X), "H"]).
|
||||
-define(ANSI_CUR_UP(N), [?ANSI_ESC, "[", integer_to_list(N), "A"]).
|
||||
-define(ANSI_CUR_DOWN(N), [?ANSI_ESC, "[", integer_to_list(N), "B"]).
|
||||
-define(ANSI_CUR_RIGHT(N), [?ANSI_ESC, "[", integer_to_list(N), "C"]).
|
||||
-define(ANSI_CUR_LEFT(N), [?ANSI_ESC, "[", integer_to_list(N), "D"]).
|
||||
-define(ANSI_CUR_SAVE, [?ANSI_ESC, "7"]).
|
||||
-define(ANSI_CUR_RESTORE, [?ANSI_ESC, "8"]).
|
||||
-define(ANSI_CUR_QUERY, [?ANSI_ESC, "[6n"]).
|
||||
|
||||
-define(ANSI_CUR_UP, ?ANSI_CUR_UP(1)).
|
||||
-define(ANSI_CUR_DOWN, ?ANSI_CUR_DOWN(1)).
|
||||
-define(ANSI_CUR_RIGHT, ?ANSI_CUR_RIGHT(1)).
|
||||
-define(ANSI_CUR_LEFT, ?ANSI_CUR_LEFT(1)).
|
||||
|
||||
|
||||
% relative movement "forward" +X=right, +Y=down
|
||||
-define(ANSI_CUR_VECT(X, Y),
|
||||
if X =< 0, Y =< 0 -> [?ANSI_CUR_LEFT(-1*X), ?ANSI_CUR_UP(-1*Y)];
|
||||
X =< 0, 0 < Y -> [?ANSI_CUR_LEFT(-1*X), ?ANSI_CUR_DOWN(Y)];
|
||||
0 < X, Y =< 0 -> [?ANSI_CUR_RIGHT(X), ?ANSI_CUR_UP(-1*Y)];
|
||||
0 < X, 0 < Y -> [?ANSI_CUR_RIGHT(X), ?ANSI_CUR_DOWN(Y)]
|
||||
end
|
||||
).
|
||||
|
||||
|
||||
|
||||
-define(ANSI_ALTBUF, [?ANSI_ESC, "[?1049h"]).
|
||||
-define(ANSI_UNALTBUF, [?ANSI_ESC, "[?1049l"]).
|
||||
|
||||
-define(ANSI_CUR_INVIS, [?ANSI_ESC, "[?25l"]).
|
||||
-define(ANSI_CUR_VIS, [?ANSI_ESC, "[?25h"]).
|
||||
|
||||
-define(ANSI_WRAP, [?ANSI_ESC, "[=7h"]).
|
||||
-define(ANSI_NOWRAP, [?ANSI_ESC, "[=7l"]).
|
||||
@@ -0,0 +1,256 @@
|
||||
In Congress, July 4, 1776
|
||||
|
||||
The unanimous Declaration of the thirteen united States of America,
|
||||
|
||||
When in the Course of human events, it becomes necessary for one
|
||||
people to dissolve the political bands which have connected them with
|
||||
another, and to assume among the powers of the earth, the separate
|
||||
and equal station to which the Laws of Nature and of Nature's God
|
||||
entitle them, a decent respect to the opinions of mankind requires
|
||||
that they should declare the causes which impel them to the
|
||||
separation.
|
||||
|
||||
We hold these truths to be self-evident, that all men are created
|
||||
equal, that they are endowed by their Creator with certain
|
||||
unalienable Rights, that among these are Life, Liberty and the
|
||||
pursuit of Happiness.--That to secure these rights, Governments are
|
||||
instituted among Men, deriving their just powers from the consent of
|
||||
the governed, --That whenever any Form of Government becomes
|
||||
destructive of these ends, it is the Right of the People to alter or
|
||||
to abolish it, and to institute new Government, laying its foundation
|
||||
on such principles and organizing its powers in such form, as to them
|
||||
shall seem most likely to effect their Safety and Happiness.
|
||||
Prudence, indeed, will dictate that Governments long established
|
||||
should not be changed for light and transient causes; and accordingly
|
||||
all experience hath shewn, that mankind are more disposed to suffer,
|
||||
while evils are sufferable, than to right themselves by abolishing
|
||||
the forms to which they are accustomed. But when a long train of
|
||||
abuses and usurpations, pursuing invariably the same Object evinces a
|
||||
design to reduce them under absolute Despotism, it is their right, it
|
||||
is their duty, to throw off such Government, and to provide new
|
||||
Guards for their future security.--Such has been the patient
|
||||
sufferance of these Colonies; and such is now the necessity which
|
||||
constrains them to alter their former Systems of Government. The
|
||||
history of the present King of Great Britain is a history of repeated
|
||||
injuries and usurpations, all having in direct object the
|
||||
establishment of an absolute Tyranny over these States. To prove
|
||||
this, let Facts be submitted to a candid world.
|
||||
|
||||
He has refused his Assent to Laws, the most wholesome and
|
||||
necessary for the public good.
|
||||
|
||||
He has forbidden his Governors to pass Laws of immediate and
|
||||
pressing importance, unless suspended in their operation till his
|
||||
Assent should be obtained; and when so suspended, he has utterly
|
||||
neglected to attend to them.
|
||||
|
||||
He has refused to pass other Laws for the accommodation of large
|
||||
districts of people, unless those people would relinquish the
|
||||
right of Representation in the Legislature, a right inestimable
|
||||
to them and formidable to tyrants only.
|
||||
|
||||
He has called together legislative bodies at places unusual,
|
||||
uncomfortable, and distant from the depository of their public
|
||||
Records, for the sole purpose of fatiguing them into compliance
|
||||
with his measures.
|
||||
|
||||
He has dissolved Representative Houses repeatedly, for opposing
|
||||
with manly firmness his invasions on the rights of the people.
|
||||
|
||||
He has refused for a long time, after such dissolutions, to cause
|
||||
others to be elected; whereby the Legislative powers, incapable
|
||||
of Annihilation, have returned to the People at large for their
|
||||
exercise; the State remaining in the mean time exposed to all the
|
||||
dangers of invasion from without, and convulsions within.
|
||||
|
||||
He has endeavoured to prevent the population of these States; for
|
||||
that purpose obstructing the Laws for Naturalization of
|
||||
Foreigners; refusing to pass others to encourage their migrations
|
||||
hither, and raising the conditions of new Appropriations of
|
||||
Lands.
|
||||
|
||||
He has obstructed the Administration of Justice, by refusing his
|
||||
Assent to Laws for establishing Judiciary powers.
|
||||
|
||||
He has made Judges dependent on his Will alone, for the tenure of
|
||||
their offices, and the amount and payment of their salaries.
|
||||
|
||||
He has erected a multitude of New Offices, and sent hither swarms
|
||||
of Officers to harrass our people, and eat out their substance.
|
||||
|
||||
He has kept among us, in times of peace, Standing Armies without
|
||||
the Consent of our legislatures.
|
||||
|
||||
He has affected to render the Military independent of and
|
||||
superior to the Civil power.
|
||||
|
||||
He has combined with others to subject us to a jurisdiction
|
||||
foreign to our constitution, and unacknowledged by our laws;
|
||||
giving his Assent to their Acts of pretended Legislation:
|
||||
|
||||
For Quartering large bodies of armed troops among us:
|
||||
|
||||
For protecting them, by a mock Trial, from punishment for any
|
||||
Murders which they should commit on the Inhabitants of these
|
||||
States:
|
||||
|
||||
For cutting off our Trade with all parts of the world:
|
||||
|
||||
For imposing Taxes on us without our Consent:
|
||||
|
||||
For depriving us in many cases, of the benefits of Trial by Jury:
|
||||
|
||||
For transporting us beyond Seas to be tried for pretended
|
||||
offences:
|
||||
|
||||
For abolishing the free System of English Laws in a neighbouring
|
||||
Province, establishing therein an Arbitrary government, and
|
||||
enlarging its Boundaries so as to render it at once an example
|
||||
and fit instrument for introducing the same absolute rule into
|
||||
these Colonies:
|
||||
|
||||
For taking away our Charters, abolishing our most valuable Laws,
|
||||
and altering fundamentally the Forms of our Governments:
|
||||
|
||||
For suspending our own Legislatures, and declaring themselves
|
||||
invested with power to legislate for us in all cases whatsoever.
|
||||
|
||||
He has abdicated Government here, by declaring us out of his
|
||||
Protection and waging War against us.
|
||||
|
||||
He has plundered our seas, ravaged our Coasts, burnt our towns,
|
||||
and destroyed the lives of our people.
|
||||
|
||||
He is at this time transporting large Armies of foreign
|
||||
Mercenaries to compleat the works of death, desolation and
|
||||
tyranny, already begun with circumstances of Cruelty & perfidy
|
||||
scarcely paralleled in the most barbarous ages, and totally
|
||||
unworthy the Head of a civilized nation.
|
||||
|
||||
He has constrained our fellow Citizens taken Captive on the high
|
||||
Seas to bear Arms against their Country, to become the
|
||||
executioners of their friends and Brethren, or to fall themselves
|
||||
by their Hands.
|
||||
|
||||
He has excited domestic insurrections amongst us, and has
|
||||
endeavoured to bring on the inhabitants of our frontiers, the
|
||||
merciless Indian Savages, whose known rule of warfare, is an
|
||||
undistinguished destruction of all ages, sexes and conditions.
|
||||
|
||||
In every stage of these Oppressions We have Petitioned for Redress in
|
||||
the most humble terms: Our repeated Petitions have been answered only
|
||||
by repeated injury. A Prince, whose character is thus marked by every
|
||||
act which may define a Tyrant, is unfit to be the ruler of a free
|
||||
people.
|
||||
|
||||
Nor have We been wanting in attentions to our Brittish brethren. We
|
||||
have warned them from time to time of attempts by their legislature
|
||||
to extend an unwarrantable jurisdiction over us. We have reminded
|
||||
them of the circumstances of our emigration and settlement here. We
|
||||
have appealed to their native justice and magnanimity, and we have
|
||||
conjured them by the ties of our common kindred to disavow these
|
||||
usurpations, which, would inevitably interrupt our connections and
|
||||
correspondence. They too have been deaf to the voice of justice and
|
||||
of consanguinity. We must, therefore, acquiesce in the necessity,
|
||||
which denounces our Separation, and hold them, as we hold the rest of
|
||||
mankind, Enemies in War, in Peace Friends.
|
||||
|
||||
We, therefore, the Representatives of the united States of America,
|
||||
in General Congress, Assembled, appealing to the Supreme Judge of the
|
||||
world for the rectitude of our intentions, do, in the Name, and by
|
||||
Authority of the good People of these Colonies, solemnly publish and
|
||||
declare, That these United Colonies are, and of Right ought to be
|
||||
Free and Independent States; that they are Absolved from all
|
||||
Allegiance to the British Crown, and that all political connection
|
||||
between them and the State of Great Britain, is and ought to be
|
||||
totally dissolved; and that as Free and Independent States, they have
|
||||
full Power to levy War, conclude Peace, contract Alliances, establish
|
||||
Commerce, and to do all other Acts and Things which Independent
|
||||
States may of right do. And for the support of this Declaration, with
|
||||
a firm reliance on the protection of divine Providence, we mutually
|
||||
pledge to each other our Lives, our Fortunes and our sacred Honor.
|
||||
|
||||
Georgia
|
||||
Button Gwinnett
|
||||
Lyman Hall
|
||||
George Walton
|
||||
North Carolina
|
||||
William Hooper
|
||||
Joseph Hewes
|
||||
John Penn
|
||||
|
||||
South Carolina
|
||||
Edward Rutledge
|
||||
Thomas Heyward, Jr.
|
||||
Thomas Lynch, Jr.
|
||||
Arthur Middleton
|
||||
|
||||
Massachusetts
|
||||
John Hancock
|
||||
|
||||
Maryland
|
||||
Samuel Chase
|
||||
William Paca
|
||||
Thomas Stone
|
||||
Charles Carroll of Carrollton
|
||||
|
||||
Virginia
|
||||
George Wythe
|
||||
Richard Henry Lee
|
||||
Thomas Jefferson
|
||||
Benjamin Harrison
|
||||
Thomas Nelson, Jr.
|
||||
Francis Lightfoot Lee
|
||||
Carter Braxton
|
||||
|
||||
Pennsylvania
|
||||
Robert Morris
|
||||
Benjamin Rush
|
||||
Benjamin Franklin
|
||||
John Morton
|
||||
George Clymer
|
||||
James Smith
|
||||
George Taylor
|
||||
James Wilson
|
||||
George Ross
|
||||
|
||||
Delaware
|
||||
Caesar Rodney
|
||||
George Read
|
||||
Thomas McKean
|
||||
|
||||
New York
|
||||
William Floyd
|
||||
Philip Livingston
|
||||
Francis Lewis
|
||||
Lewis Morris
|
||||
|
||||
New Jersey
|
||||
Richard Stockton
|
||||
John Witherspoon
|
||||
Francis Hopkinson
|
||||
John Hart
|
||||
Abraham Clark
|
||||
|
||||
New Hampshire
|
||||
Josiah Bartlett
|
||||
William Whipple
|
||||
|
||||
Massachusetts
|
||||
Samuel Adams
|
||||
John Adams
|
||||
Robert Treat Paine
|
||||
Elbridge Gerry
|
||||
|
||||
Rhode Island
|
||||
Stephen Hopkins
|
||||
William Ellery
|
||||
|
||||
Connecticut
|
||||
Roger Sherman
|
||||
Samuel Huntington
|
||||
William Williams
|
||||
Oliver Wolcott
|
||||
|
||||
New Hampshire
|
||||
Matthew Thornton
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
%%=====================================================
|
||||
%% ARG PARSING
|
||||
%%=====================================================
|
||||
|
||||
|
||||
%%-----------------------------------------------------
|
||||
%% TOKENIZING
|
||||
%%-----------------------------------------------------
|
||||
|
||||
-record{ctk,
|
||||
{shape = none :: none | '-' | '--' | str,
|
||||
val = none :: none | [char()] | string() | string(),
|
||||
str = none :: none | string()}).
|
||||
-type ctk() :: #ctk{}.
|
||||
|
||||
|
||||
|
||||
-spec tokenize(Args) -> CliTokens when
|
||||
Args :: [string()],
|
||||
CliTokens :: [ctk()].
|
||||
%% @private tokenize cli args
|
||||
|
||||
tokenize(Args) ->
|
||||
[tokenize_arg(S) || S <- Args].
|
||||
|
||||
tokenize_arg(Str = "--" ++ Val) ->
|
||||
#ctk{shape = '--',
|
||||
val = Val,
|
||||
str = Str};
|
||||
tokenize_arg(Str = "-" ++ Val) ->
|
||||
#ctk{shape = '-',
|
||||
val = Val,
|
||||
str = Str};
|
||||
tokenize_arg(Str) ->
|
||||
#ctk{shape = str,
|
||||
val = none,
|
||||
str = Str}.
|
||||
|
||||
|
||||
%%-----------------------------------------------------
|
||||
%% PARSING
|
||||
%%-----------------------------------------------------
|
||||
+185
-8
@@ -1,11 +1,5 @@
|
||||
%%% @doc
|
||||
%%% GSC CLI: gsc_cli
|
||||
%%%
|
||||
%%% This module is currently named `gsc_cli', but you may want to change that.
|
||||
%%% Remember that changing the name in `-module()' below requires renaming
|
||||
%%% this file, and it is recommended to run `zx update .app` in the main
|
||||
%%% project directory to make sure the ebin/gsc_cli.app file stays in
|
||||
%%% sync with the project whenever you add, remove or rename a module.
|
||||
%%% GSC CLI: explorer/harness for sfc iteration
|
||||
%%% @end
|
||||
|
||||
-module(gsc_cli).
|
||||
@@ -16,10 +10,193 @@
|
||||
|
||||
-export([start/1]).
|
||||
|
||||
-include("$gsc_include/gsc.hrl").
|
||||
-include("ansi.hrl").
|
||||
|
||||
do_help() ->
|
||||
io:format("~ts", [help_screen()]).
|
||||
|
||||
help_screen() ->
|
||||
["you can't help people who refuse to help themsleves\n"].
|
||||
|
||||
-spec start(ArgV) -> ok
|
||||
when ArgV :: [string()].
|
||||
|
||||
start([]) ->
|
||||
do_eshell(),
|
||||
ok;
|
||||
start(["shell"]) ->
|
||||
do_eshell(),
|
||||
ok;
|
||||
start(["eshell"]) ->
|
||||
do_eshell(),
|
||||
ok;
|
||||
start(ArgV) ->
|
||||
ok = io:format("Hello, World! Args: ~tp~n", [ArgV]),
|
||||
%io:format("ArgV: ~p~n", [ArgV]),
|
||||
do(ArgV),
|
||||
zx:silent_stop().
|
||||
|
||||
do(["list"]) ->
|
||||
do_tlist();
|
||||
do(["list", "tests"]) ->
|
||||
do_tlist();
|
||||
do(["run", "tests"]) ->
|
||||
io:format("TestModules = ~p~n", [known_modules_with_prefix("ts")]),
|
||||
do_runall_tests();
|
||||
do(["tokenizers_agree", Foo]) ->
|
||||
io:format("~p~n", [tokenizers_agree(Foo)]);
|
||||
% slowly phasing out shitty names like lctokens
|
||||
% tokens = native sfc token representation
|
||||
do(["tokens", Foo]) -> do_tokens(Foo);
|
||||
do(["color_tokens", Foo]) -> do_color_tokens(Foo);
|
||||
do(["ctokens", Foo]) -> do_color_tokens(Foo);
|
||||
do(["colour_tokens" | _]) -> do_doi();
|
||||
% so_tokens = so_scan tokens
|
||||
do(["so", "tokens", Foo]) -> do_so_tokens(Foo);
|
||||
do(["so_tokens", Foo]) -> do_so_tokens(Foo);
|
||||
% gso_tokens = our mockery
|
||||
do(["gso", "tokens", Foo]) -> do_gso_tokens(Foo);
|
||||
do(["gso_tokens", Foo]) -> do_gso_tokens(Foo);
|
||||
% print source file to screen with token boundaries highlighted
|
||||
% script utility
|
||||
do(["rmm", Foo]) ->
|
||||
do_rmm(Foo);
|
||||
do(Args) ->
|
||||
io:format("bad args: ~p~n", [Args]),
|
||||
do_help().
|
||||
|
||||
do_doi() ->
|
||||
FP = zx:get_home() ++ "/priv/doi.txt",
|
||||
Cmd = "less " ++ FP,
|
||||
io:format("~s~n", [Cmd]).
|
||||
|
||||
|
||||
do_runall_tests() ->
|
||||
lists:foreach(fun run_mod_main/1, test_mods()).
|
||||
|
||||
test_mods() ->
|
||||
known_modules_with_prefix("gt_").
|
||||
|
||||
known_modules_with_prefix(Pfx) ->
|
||||
ModsZipBeamsZipLoaded = code:all_available(),
|
||||
kmp(Pfx, ModsZipBeamsZipLoaded, []).
|
||||
|
||||
kmp(_Pfx, [], Acc) ->
|
||||
lists:sort(Acc);
|
||||
kmp(Pfx, [{ModStr, _BeamPath, _Loaded} | Rest], Acc) ->
|
||||
case lists:prefix(Pfx, ModStr) of
|
||||
false -> kmp(Pfx, Rest, Acc);
|
||||
true -> kmp(Pfx, Rest, [list_to_atom(ModStr) | Acc])
|
||||
end.
|
||||
|
||||
run_mod_main(Mod) ->
|
||||
io:format("========================================\n"
|
||||
"~p:main()\n"
|
||||
"========================================\n",
|
||||
[Mod]),
|
||||
try
|
||||
Mod:main()
|
||||
catch
|
||||
Err:ErrType:Trace ->
|
||||
io:format("~p: ~p~n", [Err, ErrType]),
|
||||
io:format("Trace:~n~p~n", [Trace])
|
||||
end.
|
||||
|
||||
do_tlist() ->
|
||||
lists:foreach(
|
||||
fun(ModName) ->
|
||||
io:format("~s~n", [ModName])
|
||||
end,
|
||||
test_mods()
|
||||
).
|
||||
|
||||
|
||||
-spec do_eshell() -> ok.
|
||||
% @doc start an erlang shell
|
||||
|
||||
do_eshell() ->
|
||||
io:format("Welcome to the GSC shell!~n", []),
|
||||
case shell:start_interactive() of
|
||||
ok -> ok;
|
||||
{error, already_started} -> ok;
|
||||
{error, Reason} -> error(Reason)
|
||||
end.
|
||||
|
||||
tokenizers_agree(File) ->
|
||||
so_tokens(File) =:= tokens(File).
|
||||
|
||||
|
||||
do_tokens(FilePath) ->
|
||||
[io:format("~p~n", [Tk]) || Tk <- tokens(FilePath)].
|
||||
|
||||
do_so_tokens(FilePath) ->
|
||||
[io:format("~p~n", [Tk]) || Tk <- so_tokens(FilePath)].
|
||||
|
||||
do_gso_tokens(FilePath) ->
|
||||
[io:format("~p~n", [Tk]) || Tk <- gso_tokens(FilePath)].
|
||||
|
||||
|
||||
% rmm = run module:main() with our context loaded
|
||||
% useful for prototyping
|
||||
do_rmm(FilePath) ->
|
||||
case compile:file(FilePath) of
|
||||
{ok, Mod} -> Mod:main();
|
||||
Error -> error(Error)
|
||||
end.
|
||||
|
||||
|
||||
so_tokens(FilePath) ->
|
||||
{ok, FileBytes} = file:read_file(FilePath),
|
||||
FileStr = unicode:characters_to_nfc_list(FileBytes),
|
||||
{ok, Tokens} = so_scan:scan(FileStr),
|
||||
Tokens.
|
||||
|
||||
gso_tokens(FilePath) ->
|
||||
{ok, FileBytes} = file:read_file(FilePath),
|
||||
FileStr = unicode:characters_to_nfc_list(FileBytes),
|
||||
{ok, Tokens} = gso_scan:scan(FileStr),
|
||||
Tokens.
|
||||
|
||||
|
||||
tokens(FilePath) ->
|
||||
{ok, Tokens} = gsc:tokens_from_file(FilePath),
|
||||
Tokens.
|
||||
|
||||
|
||||
do_color_tokens(File) ->
|
||||
case gsc:tokens_from_file(File) of
|
||||
{ok, Tokens} ->
|
||||
ColorizedSrcStr = colorize_tokens(chunk_color_wheel(), Tokens, ""),
|
||||
Full = [?ANSI_INVERT, ColorizedSrcStr, ?ANSI_UNINVERT],
|
||||
io:format("~s", [Full]);
|
||||
Error ->
|
||||
io:format("~p~n", [Error])
|
||||
end.
|
||||
|
||||
chunk_color_wheel() ->
|
||||
%[yellow, blue].
|
||||
[red, green, yellow, blue, magenta, cyan].
|
||||
|
||||
|
||||
|
||||
colorize_tokens(Wheel, [T | Ts], Acc) ->
|
||||
{Color, NewWheel} = rotate(Wheel),
|
||||
NewAcc = [Acc, colorize_token_str(Color, T)],
|
||||
colorize_tokens(NewWheel, Ts, NewAcc);
|
||||
colorize_tokens(_, [], Acc) ->
|
||||
Acc.
|
||||
|
||||
rotate([A | Rest]) ->
|
||||
{A, Rest ++ [A]}.
|
||||
|
||||
colorize_token_str(Color, #tk{str = Str}) ->
|
||||
{Pfx, Sfx} = color_fixes(Color),
|
||||
[Pfx, Str, Sfx].
|
||||
|
||||
color_fixes(red) -> {?ANSI_FG_RED, ?ANSI_FG_RESET};
|
||||
color_fixes(green) -> {?ANSI_FG_GREEN, ?ANSI_FG_RESET};
|
||||
color_fixes(yellow) -> {?ANSI_FG_YELLOW, ?ANSI_FG_RESET};
|
||||
color_fixes(blue) -> {?ANSI_FG_BLUE, ?ANSI_FG_RESET};
|
||||
color_fixes(magenta) -> {?ANSI_FG_MAGENTA, ?ANSI_FG_RESET};
|
||||
color_fixes(cyan) -> {?ANSI_FG_CYAN, ?ANSI_FG_RESET}.
|
||||
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
% gsc tokenizer tests
|
||||
-module(tsfp_gsc_tokenizer).
|
||||
|
||||
-export([
|
||||
main/0, ct_dir/0
|
||||
%tokens_match/1
|
||||
]).
|
||||
-include("$gsc_include/gsc.hrl").
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
main() ->
|
||||
%io:format("~p~n", [div_files()]),
|
||||
%io:format("MAINNNNN!~n", []),
|
||||
eunit:test(?MODULE, [verbose]).
|
||||
%eunit:test(?MODULE).
|
||||
|
||||
|
||||
% directory containing the tests for the tokenizer
|
||||
ct_dir() ->
|
||||
zx_daemon:get_home() ++ "/test-data/gt_tokens".
|
||||
|
||||
agreement_tests_dir() ->
|
||||
ct_dir() ++ "/tokenizers_agree".
|
||||
|
||||
|
||||
% the divergences claude found between gsc tokenizer and so tokenizer
|
||||
%
|
||||
% mostly stupid corner cases like a string crossing a line boundary
|
||||
% or unterminated block comment
|
||||
%
|
||||
% divergence files: "divergence" means so_scan disagrees with
|
||||
% gsc_so_scan in one of the following ways:
|
||||
%
|
||||
% - one succeeds when the other errors
|
||||
% - disagree on success case
|
||||
%
|
||||
% making errors agree on two programs that work differently is a
|
||||
% fool's errand
|
||||
div_files() ->
|
||||
ContractsDir = agreement_tests_dir(),
|
||||
% this is the equivalent of ls
|
||||
% just has filenames, no /path/to/ prefix
|
||||
{ok, Files} = file:list_dir(ContractsDir),
|
||||
% originally i was a retard and didn't read the eunit
|
||||
% documentation, so if any one test failed, the entire test suite
|
||||
% would crash with no information regarding what happened
|
||||
%
|
||||
% so this was a hack to only run div01-div05 but not div06:
|
||||
%
|
||||
% % hack to fix one broken test at a time
|
||||
% (FileName = "div0" ++ [Digit | _]) when Digit =< $9 ->
|
||||
% FilePath = ct_dir() ++ "/" ++ FileName,
|
||||
% {true, {FileName, FilePath}}
|
||||
% (_) -> false
|
||||
%
|
||||
% Once i read the eunit docs and learned about test generators, I
|
||||
% realized I could have only the failed test chimp out. what a
|
||||
% concept.
|
||||
%
|
||||
% i also realized that printing the full filepath was a waste, so
|
||||
% instead the test should know about the FileName (foo.bar) and the
|
||||
% FilePath (/path/to/foo.bar).
|
||||
%
|
||||
% then i decided to start writing my own test contracts instead
|
||||
% of having claude do it and i rean into the issue of vim swap
|
||||
% files not lexing properly because they're not unicode
|
||||
IsDivCt =
|
||||
fun(FileName) ->
|
||||
% need to filter out vim swap files
|
||||
% originally was false-matching on ([$. | _])
|
||||
% like a man
|
||||
%
|
||||
% god this feels like putting my balls in a little tiny
|
||||
% guillotine (even the guillotine is emasculating) but
|
||||
% claude suggested this and i mean it's kind of the
|
||||
% most idiomatic and like straightforward. most
|
||||
% importantly it's declarative
|
||||
%
|
||||
% god i feel so defeated
|
||||
case filename:extension(FileName) of
|
||||
".aes" ->
|
||||
FilePath = ContractsDir ++ "/" ++ FileName,
|
||||
{true, {FileName, FilePath}};
|
||||
_ ->
|
||||
false
|
||||
end
|
||||
end,
|
||||
lists:sort(lists:filtermap(IsDivCt, Files)).
|
||||
|
||||
|
||||
%div_file_names() -> [N || {N, _} <- div_files()].
|
||||
%div_file_paths() -> [P || {_, P} <- div_files()].
|
||||
|
||||
tokstr_concat_test_() ->
|
||||
% future proofing
|
||||
ConcatTestFiles
|
||||
= lists:flatten([
|
||||
div_files()
|
||||
]),
|
||||
% exclude the contracts with like unterminated block comments
|
||||
% where they don't tokenize properly
|
||||
NonStupidFiles =
|
||||
lists:filter(
|
||||
fun
|
||||
({"div05_bcom_eof.aes", _}) -> false;
|
||||
({"div06_bcom_in_expr.aes", _}) -> false;
|
||||
({"div07_bcom_nested.aes", _}) -> false;
|
||||
({"div08_bcom_simple.aes", _}) -> false;
|
||||
({_, _}) -> true
|
||||
end,
|
||||
ConcatTestFiles
|
||||
),
|
||||
%?debugFmt("ConcatTestFiles=~p", [ConcatTestFiles]),
|
||||
{"file = sum(tokens)",
|
||||
[concat_property(Name, Path) || {Name, Path} <- NonStupidFiles]}.
|
||||
|
||||
concat_property(FileName, FilePath) ->
|
||||
%?debugFmt("concat_property(~p, _)", [FileName]),
|
||||
{ok, FileBytes} = file:read_file(FilePath),
|
||||
FileChars = unicode:characters_to_nfc_list(FileBytes),
|
||||
{FileName ++ ": file = sum(tokens)",
|
||||
fun() ->
|
||||
case gsc_tokenizer:tokens(FileChars) of
|
||||
{ok, SfcTokens} ->
|
||||
ConcatStr = concat_token_strs(SfcTokens, []),
|
||||
?assertEqual(FileChars, ConcatStr);
|
||||
_Error ->
|
||||
ok
|
||||
end
|
||||
end}.
|
||||
|
||||
concat_token_strs([#gsc_token{string = S} | Rest], Acc) ->
|
||||
concat_token_strs(Rest, [Acc, S]);
|
||||
concat_token_strs([], Acc) ->
|
||||
unicode:characters_to_nfc_list(Acc).
|
||||
|
||||
% underscore marks this as a test *generator*
|
||||
div_test_() ->
|
||||
% divergence
|
||||
DivFiles = div_files(),
|
||||
%?debugFmt("DivFiles=~p", [DivFiles]),
|
||||
{"claude tokenizer divergences fixed", [tokens_match(N, P) || {N, P} <- DivFiles]}.
|
||||
|
||||
tokens_match(FileName, FilePath) ->
|
||||
%?debugFmt("tokens_match(~p, _)", [FileName]),
|
||||
% extracting data to be tested
|
||||
SoTokens = sfp:so_tokens(FilePath),
|
||||
SfTokens = sfp:gsc_so_tokens(FilePath),
|
||||
{FileName ++ ": tokenizers_agree",
|
||||
fun() ->
|
||||
case {SoTokens, SfTokens} of
|
||||
{{ok, So}, {ok, Sf}} -> ?assertEqual(So, Sf);
|
||||
{{error, _}, {error, _}} -> ok;
|
||||
{{ok, _}, {error, _}} -> error("so_scan succeeded and gsc_so_scan failed");
|
||||
{{error, _}, {ok, _}} -> error("so_scan failed and gsc_so_scan succeded")
|
||||
end
|
||||
end}.
|
||||
+2
-2
@@ -2,11 +2,11 @@
|
||||
{type,cli}.
|
||||
{modules,[]}.
|
||||
{mod,"gsc_cli"}.
|
||||
{prefix,none}.
|
||||
{author,"Peter Harpending"}.
|
||||
{prefix,none}.
|
||||
{desc,"GSC CLI and test suite"}.
|
||||
{package_id,{"otpr","gsc_cli",{0,1,0}}}.
|
||||
{deps,[{"otpr","gsc",{0,1,0}}]}.
|
||||
{deps,[{"otpr","sophia",{9,0,0}},{"otpr","gsc",{0,1,0}}]}.
|
||||
{key_name,none}.
|
||||
{a_email,"peterharpending@qpq.swiss"}.
|
||||
{c_email,"peterharpending@qpq.swiss"}.
|
||||
|
||||
Reference in New Issue
Block a user