Skip to content

[WIP] Add lang: TeX#265

Draft
jared-hughes wants to merge 12 commits into
mainfrom
addlang-tex
Draft

[WIP] Add lang: TeX#265
jared-hughes wants to merge 12 commits into
mainfrom
addlang-tex

Conversation

@jared-hughes

@jared-hughes jared-hughes commented Nov 11, 2023

Copy link
Copy Markdown
Collaborator

Will want to improve before merging.

Currently producing some nasty code for fibonacci:

\newcount\a\newcount\b\newcount\i\newcount\t\newcount\T\newcount~\a0 \b1 \i0
\def\c{{\ifnum\i<31 \the\a\endgraf\t\a\advance\t\b\T\t\a\b\b\T~1 \advance~\i\i~\c\fi}}\c

Some TODOs for correctness:

  • there's excess curly braces there: Should be \def\c{...}, not \def\c{{...}}.
  • Tons in the code
  • Test on some solutions other than fibonacci.

Some TODOs for golfing:

  • ~ should get chosen earlier by frequency
  • Better 2AC conversion. Can be done at creation time, or post-hoc logic similar to tempVarToMultipleAssignment.
  • Tons in the code

Comment thread src/IR/IR.ts
Comment thread src/common/emit.ts Outdated
Comment thread src/common/stringify.ts Outdated
Comment thread src/languages/tex/plugins.ts Outdated
Comment thread src/languages/tex/plugins.ts Outdated
Comment thread src/languages/tex/emit.ts
import { SPACE_ANTIGOBBLE } from "./detokenizer";

// TODO-tex: somehow deal with quoting text, e.g. '#' cannot be written as-is.
// TODO-tex: <=, >=,!= are unsupported. Plugin to convert to >,<,=

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golfscript does this, but there's no dedicated plugin

Comment thread src/IR/terminals.ts
Had accidentally changed it so that would only work when the node was a child of a block, which turned out to be not always.
Reverts "revert forRangeToWhile block requirement"

Now, `forRangeToWhile` will only apply to a ForRange that is either the direct child of a block, or is the root node.

The test was failing because the plugin didn't apply to root node. But the old implementation using visit() directly didn't work because error "attempt to insert a block into a block".
@MichalMarsalek MichalMarsalek added the newlang New language target label Nov 24, 2023
@MichalMarsalek MichalMarsalek marked this pull request as draft November 29, 2023 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

newlang New language target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants