### Basic CMakeLists.txt Configuration
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/CMake/filenames/CMakeLists.txt
Sets up the minimum CMake version, project name, installation prefix, and includes a subdirectory. This is a foundational setup for most CMake projects.
```cmake
cmake_minimum_required(VERSION 2.8)
project(Foo)
set(CMAKE_SKIP_RPATH TRUE)
set(CMAKE_INSTALL_PREFIX "/usr/local")
add_subdirectory(bar)
```
--------------------------------
### Install Hyperpolyglot CLI
Source: https://github.com/monkslc/hyperpolyglot/blob/master/README.md
Use cargo to install the command-line tool.
```bash
cargo install hyperpolyglot
```
--------------------------------
### CLI Output Example
Source: https://github.com/monkslc/hyperpolyglot/blob/master/README.md
Example output showing language distribution percentages.
```text
85.00% Rust
15.00% RenderScript
```
--------------------------------
### Install pkgdown
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/HTML/pkgdown.html
Install the release version from CRAN or the development version from GitHub.
```r
install.packages("pkgdown")
```
```r
devtools::install_github("r-lib/pkgdown")
```
--------------------------------
### Building and Installing an Executable with CMake
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/CMake/filenames/CMakeLists.txt
Defines an executable target, links it with the pthread library, and specifies its installation path. Ensure the source file 'foo.c' exists in the same directory.
```cmake
add_executable(foo foo.c)
target_link_libraries(foo pthread)
install(TARGETS foo DESTINATION bin)
```
--------------------------------
### Install org-ruby gem
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Org/org.org
Command to install the org-ruby gem via terminal.
```bash
sudo gem install org-ruby
```
--------------------------------
### Develop SciPy with Symlink Install
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/reStructuredText/HACKING.rst.txt
Use `setupegg.py develop` for a symlink install, which integrates your development version into Python's site-packages. This is an alternative to modifying PYTHONPATH.
```bash
python setupegg.py develop --prefix=${HOME}
```
--------------------------------
### Install Next.js Dependencies
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Markdown/sample.mdx
Installs the necessary Next.js, React, and ReactDOM packages using Yarn.
```bash
yarn add next react react-dom
```
--------------------------------
### Webby page source example
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Org/org.org
Example of a Webby page source file using Markdown and YAML metadata.
```yaml
---
title: Special Directories
created_at: 2009-12-17
status: Complete
filter:
- erb
- maruku
tags:
- powershell
---
<%= @page.title %>
==================
Special Directories are a set of directories, each of which has a
function that will navigate you to the appropriate directory using
the push-location cmdlet. For example, the function `home` might
navigate to `c:\users\bdewey.`
Install
-------
Copy the module to somewhere in `ENV:PSModulePath`. Then,
InstallModule SpecialDirectories
```
--------------------------------
### Function Call Optimization
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Examples of using PUSHJ and POPJ for function calls and returns.
```Assembly
;; static
;; foo (void **p, void *f) FOO:
;; { PUSHJ 1,(2)
;; *++p = &&label; POPJ 17,
;; goto *f;
;; label:
;; return;
;; }
```
```Assembly
;; static void
;; bar (void **p) BAR:
;; { POPJ 1,
;; goto *p--;
;; }
```
--------------------------------
### Get Language Breakdown
Source: https://github.com/monkslc/hyperpolyglot/blob/master/README.md
Analyze a directory to get a breakdown of languages present.
```Rust
use hyperpolyglot::{get_language_breakdown};
let breakdown: HashMap<&'static str, Vec<(Detection, PathBuf)>> = get_language_breakdown("src/");
println!("{:?}", breakdown.get("Rust"));
```
--------------------------------
### Next.js Home Page Example
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Markdown/sample.mdx
A basic React component for the home page of a Next.js application.
```jsx
export default () =>
Hello world!
```
--------------------------------
### 72-bit Signed Right Shift (Variable Amount) Example
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Performs a signed right shift on a 72-bit number (AC1:AC2) by a variable amount (AC3). This example includes a loop for larger shifts and uses ashc/ash for the operation.
```assembly
; only works if n <= 35
movn 4,3 ; operand in AC1:AC2, shift amount in AC3
lshc 1,4
lsh 1,3
ash 1,4 ; result in AC1:AC2
; loop
jumple 3,.+5
lshc 1,-1
tlne 1,200000
tlo 1,400000
sojg 3,.-3
; only works if n <= 70
tlnn 1,400000
tdza 4,4
movsi 4,400000
movei 5,0
ashc 4,3
lsh 5,1
lshc 1,3
ior 1,4
ior 2,5
```
--------------------------------
### Utility and Security Routines
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/TI Program/srcfunc.8xp.txt
Routines for archiving status, access verification, and new keycode installation.
```Axe Parser
Lbl D3
.archiving box
sub(D2,15,22,66,20,"Archiving...")
Text(17,31,"Please wait...")
Return
Lbl CODE
sub(D2,15,22,66,20,"Access Denied")
Text(29,32," - - - - ")
DispGraph
1->[r2]
Repeat getKey->[r1]
End
Text(29,32,"*")
DispGraph
If [r1]!=({[Y1]+1})
0->[r2]
End
Repeat getKey->[r1]
End
Text(39,32,"*")
DispGraph
If [r1]!=({[Y1]+2})
0->[r2]
End
Repeat getKey->[r1]
End
Text(49,32,"*")
DispGraph
If [r1]!=({[Y1]+3})
0->[r2]
End
Repeat getKey->[r1]
End
Text(59,32,"*")
DispGraph
If [r1]!=({[Y1]+4})
0->[r2]
End
Normal
Pause 200
Full
Return[r2]
Lbl NEW
ClrDraw
sub(D1,0,0)
RectI(0,11,96,1)
Text(1,12,"Installation")
Text(1,20,"Enter your new keycode:")
Text(1,26," - - - - ")
DispGraph
GetCalc(Str1,16)->[r1]
Fill([r1],16,1)
0->{[r1]}
Repeat getKey->[r2]
End
[r2]->{[r1]+1}
Text(1,26,"*")
DispGraph
Repeat getKey->[r2]
End
[r2]->{[r1]+2}
Text(7,26,"*")
DispGraph
Repeat getKey->[r2]
End
[r2]->{[r1]+3}
Text(13,26,"*")
DispGraph
Repeat getKey->[r2]
End
[r2]->{[r1]+4}
Text(19,26,"*")
DispGraph
Fill(L1,50,0)
Text(1,34,"Confirm keycode:")
Text(1,40," - - - - ")
DispGraph
Repeat getKey->[r2]
End
[r2]->{L1+1}
Text(1,40,"*")
DispGraph
Repeat getKey->[r2]
End
[r2]->{L1+2}
Text(7,40,"*")
DispGraph
Repeat getKey->[r2]
End
[r2]->{L1+3}
Text(13,40,"*")
DispGraph
Repeat getKey->[r2]
End
[r2]->{L1+4}
Text(19,40,"*")
DispGraph
If ({[r1]+1}={L1+1}) and ({[r1]+2}={L1+2}) and ({[r1]+3}={L1+3}) and ({[r1]+4}={L1+4})
sub(D3)
DispGraph
GetCalc(Str2,10)
Archive Str1
GetCalc(Str1,[Y1])
ClrDraw
Return
Else
Text(1,48,"ERROR keycodes do not")
Text(1,54,"match.")
DispGraph
UnArchive Str1
DelVar Str1
Repeat getKey
End
Goto END
End
Return
Lbl END
Asm(FDCB249E)
If {[Y1]+6}
Asm(FDCB24DE)
End
ClrDraw
ClrDraw^^r
ClrHome
Return^^r
```
--------------------------------
### Document Ruby classes and methods
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/RDoc/rdoc.rdoc
Example of using RDoc comments above class and method definitions.
```ruby
##
# This class represents an arbitrary shape by a series of points.
class Shape
##
# Creates a new shape described by a +polyline+.
#
# If the +polyline+ does not end at the same point it started at the
# first pointed is copied and placed at the end of the line.
#
# An ArgumentError is raised if the line crosses itself, but shapes may
# be concave.
def initialize polyline
# ...
end
end
```
--------------------------------
### Webby content file with org filter
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Org/org.org
Example of a content file configured to use the org filter.
```yaml
---
title: Orgmode Parser
created_at: 2009-12-21
status: Under development
filter:
- erb
- org
tags:
- orgmode
- ruby
---
<%= @page.title %>
Status: <%= @page.status %>
* Description
Helpful Ruby routines for parsing orgmode files. The most
significant thing this library does today is convert orgmode files
to textile. Currently, you cannot do much to customize the
conversion. The supplied textile conversion is optimized for
extracting "content" from the orgfile as opposed to "metadata."
* History
** 2009-12-29: Version 0.4
- The first thing output in HTML gets the class "title"
- HTML output is now indented
- Proper support for multi-paragraph list items.
See? This paragraph is part of the last bullet.
- Fixed bugs:
- "rake spec" wouldn't work on Linux. Needed "require 'rubygems'".
```
--------------------------------
### Conditional Jump Example: CAM
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Compare and move. Used for comparing values and conditional branching.
```assembly
CAM
```
--------------------------------
### Floating-point Conversion Example: GDBLE
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Converts a single-precision floating-point number to double precision.
```assembly
GDBLE
```
--------------------------------
### Configure Max Lambda Size for @now/next Builder
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Markdown/sample.mdx
An example of how to configure the maximum output bundle size for a Next.js lambda within the `now.json` build configuration.
```json
{
"builds": [
{ "src": "next.config.js", "use": "@now/next", "config": { "maxLambdaSize": "10mb" } }
]
}
```
--------------------------------
### 71-bit Unsigned Multiplication Example
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Demonstrates 71-bit unsigned multiplication using a sequence of shift and multiply operations. The result is accumulated in AC2 and AC1.
```assembly
mul 1,3 ; multiply AC1 by AC3
lsh 2,1
lshc 1,-1 ; result in AC2
```
--------------------------------
### Floating-point Conversion Example: GSNGL
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Converts a double-precision floating-point number to single precision.
```assembly
GSNGL
```
--------------------------------
### Conditional Jump Example: CAI
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Compare and increment. Used for loop control and conditional branching.
```assembly
CAI
```
--------------------------------
### Conditional Jump Example: SOS
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Subtract and skip if zero. Used for loop termination and counting.
```assembly
SOS
```
--------------------------------
### Initialize AlphaCS Application
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/TI Program/srcalpha.8xp.txt
Initializes the application environment, including key checks, icon definitions, and program flow setup.
```TI-BASIC
.AlphaCS
#ExprOff
If getKey(41)
sub(ADM)
End
Lbl START
"appv alpha "->Str1
"appvAlphaCS"->Str2
.ALPHA CS
[7EFFFFE7FFFFE7E7]->Pic11
[E0E0E0E0E0FFFF7F]->Pic12
[FEFFE7FFFEE0E0E0]->Pic13
[E7E7E7FFFFE7E7E7]->Pic14
[7EFFFFE7FFFFE7E7]->Pic15
[7FFFFFE0E0FFFF7F]->Pic16
[7FFFFF781EFFFFFE]->Pic17
.arch
[0038447C44440000]->Pic21
.hide
[0054004400540000]->Pic22
.lock
[0038447C7C7C0000]->Pic23
.(c) Scott Mangiapane
Data(72,8)->GDB0
[42600A360008000100994DDF2A6C61B1B28091294A22AAAAAAAB005A6DCA226A69B9A9800000000000202000000000000000C0200000000000000000000000000000000000000000]
.icon unknown
Data(16,16)->GDB11
[EFFEA803EB8308032BFB28032BFB0803EBFBA803EBFB08032B8328032FFF07FF]
.icon SRC
Data(16,16)->GDB12
[01801A583E7C3FFC3FFC3E7C1A580A500240FFFFC471BDAFCC6FF5AF8DB1FFFF]
.icon ASM
Data(16,16)->GDB13
[FFFFFFFFFFFFFFFFFFFFCE6BB5D586D5B75DB4DDFFFFFFFFFFFFFFFFFFFFFFFF]
.icon shell
Data(16,16)->GDB14
[FFFFFFFFFFFFFFFFFFFFFFFF97B5B155D5359595FFFFFFFFFFFFFFFFFFFFFFFF]
Goto SET
prgmSRCFUNC
prgmSRCGUI
prgmSRCSORT
Lbl SET
.start, set up
ClrDraw
StoreGDB
DiagnosticOff
Fix 5
Full
!If GetCalc(Str1,[Y1])
sub(NEW)
StoreGDB
End
GetCalc(Str1,[Y1])
If {[Y1]+0}
!If sub(CODE)
Goto END
End
End
Asm(FDCB249E)
If {[Y1]+6}
Asm(FDCB24DE)
End
Goto DLIST
```
--------------------------------
### Conditional Jump Example: SOJ
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Subtract and skip if greater. Used for loop termination and counting.
```assembly
SOJ
```
--------------------------------
### 72-bit Addition Example
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Performs 72-bit addition using two accumulator pairs (AC1:AC2 and AC3:AC4). The result is stored in AC1 and AC2. Requires careful handling of carry.
```assembly
jfcl 17,.+1 ; add AC1 and AC2 to AC3 and AC4
add 2,4
jcry0 [aoja 1,.+1]
add 1,3 ; result in AC1 and AC2
```
--------------------------------
### 72-bit Magnitude Example
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Calculates the magnitude of a 72-bit number in AC1:AC2. This involves conditional negation and bitwise operations.
```assembly
; conditional negation
jumpge 1,.+4
setca 1,
jumpe 2,[aoja 1,.+2]
movn 2,2
; mask = x >> 71 (arithmetic shift)
; y = (x ^ mask) - mask
move 3,1
ash 1,-43 ; shortcut
xor 1,3
xor 2,3
jfcl 17,.+1
sub 2,3
jcry0 [aoja 1,.+1]
```
--------------------------------
### Conditional Jump Example: AOJ
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Add and skip if zero. Used for counting or accumulating values.
```assembly
AOJ
```
--------------------------------
### Unconditional Jump Example: PUSHJ
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Push return address and jump. A common way to call subroutines, saving the return address on the stack.
```assembly
PUSHJ
```
--------------------------------
### Conditional Jump Example: JUMP
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Unconditional jump. Used for simple control flow changes.
```assembly
JUMP
```
--------------------------------
### Conditional Jump Example: SKIP
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Skips the next instruction if a condition is met. Used for conditional execution.
```assembly
SKIP
```
--------------------------------
### Floating-point Conversion Example: FIX
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Converts a floating-point number to an integer. Variants DFIX and GFIX handle different floating-point precisions.
```assembly
FIX
```
```assembly
DFIX
```
```assembly
GFIX
```
--------------------------------
### Use Specific Thread Count
Source: https://context7.com/monkslc/hyperpolyglot/llms.txt
Specify the exact number of threads to use for analysis by setting the HYPLY_THREADS environment variable. This example uses 4 threads.
```bash
HYPLY_THREADS=4 hyply /large/project
```
--------------------------------
### Conditional Jump Example: JFFO
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Jump if first or only. Used for conditional branching based on specific flags.
```assembly
JFFO
```
--------------------------------
### 72-bit Negation Example
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Negates a 72-bit number stored in AC1:AC2. Uses setcm and movn instructions, with a jump to handle self-negation.
```assembly
setcm 1,3
movn 2,4
jumpe 2,[aoja 1,.+1]
; to self
setca 1,
jumpe 2,[aoja 1,.+2]
movn 2,2
```
--------------------------------
### Integer Conversion Example: SEXT
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
The SEXT instruction performs sign extension. It's often used in conjunction with HRRE or HRR for integer conversions.
```assembly
SEXT
```
--------------------------------
### 72-bit Subtraction Example
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Performs 72-bit subtraction using two accumulator pairs (AC1:AC2 and AC3:AC4). The result is stored in AC1 and AC2. Handles borrow correctly.
```assembly
jfcl 17,.+1 ; add AC1 and AC2 to AC3 and AC4
sub 2,4
jcry0 .+2
subi 1,1
sub 1,3 ; result in AC1 and AC2
```
--------------------------------
### Pointer Arithmetic Example: ADJBP
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Adjusts a pointer by a specified value. Similar to IBP but can also decrement.
```assembly
ADJBP
```
--------------------------------
### Pointer Arithmetic Example: SUBBP
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Decrements a pointer by a specified value. Used for moving pointers backward in memory.
```assembly
SUBBP
```
--------------------------------
### 72-bit Signed Right Shift (Fixed Amount) Example
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Performs a signed right shift on a 72-bit number by a fixed amount 'n'. Uses lshc, tlne, tlo, and skipge instructions.
```assembly
lshc 1,-n
tlne 1,mask1
tlo 1,mask2
skipge 1 ; or cail 1,0 or jumpge 1,.+2 or tlne 1,400000
iori 2,<2^n-1>
rotc 1,-n
```
--------------------------------
### Floating-point Conversion Example: FLTR
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Converts a floating-point number to a shorter floating-point format. DFLTR and GFLTR handle different precisions.
```assembly
FLTR
```
```assembly
DFLTR
```
```assembly
GFLTR
```
--------------------------------
### Build pkgdown Site
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/HTML/pkgdown.html
Run this command from your package directory to generate the documentation site. It creates a 'docs/' directory.
```r
pkgdown::build_site()
```
--------------------------------
### Generate documentation via command line
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/RDoc/rdoc.rdoc
Standard command-line usage for generating documentation from source files.
```bash
$ rdoc [options] [names...]
```
```bash
$ rdoc --help
```
```bash
$ rdoc
```
```bash
% rdoc --main README.rdoc
```
--------------------------------
### Run SciPy Tests
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/reStructuredText/HACKING.rst.txt
Execute the SciPy test suite within a Python interpreter to verify your setup and development changes. Ensure you are not inside the scipy/ source directory when running this command.
```python
import scipy as sp
sp.test()
```
--------------------------------
### Configuration Menu System
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/TI Program/srcgui.8xp.txt
A menu-driven interface for toggling settings and managing application state.
```TI-BASIC
Lbl DSET1
21->B
{[Y1]+5}->X
{[Y1]}->Y
{[Y1]+6}->Z
Lbl DSET2
ClrDraw
sub(D1,0,0)
RectI(0,11,96,1)
Text(1,12,"by ClrDraw, Nov 2013, v 1")
RectI(0,19,96,1)
RectI(0,63,96,1)
If X
Text(1,21,"Show Hidden On")
Else
Text(1,21,"Show Hidden Off")
End
If Y
Text(1,28,"Password On")
Else
Text(1,28,"Password Off")
End
If Z
Text(1,35,"Lowercase On")
Else
Text(1,35,"Lowercase Off")
End
Text(1,42,"Uninstall AlphaCS")
Lbl KSET
RectI(0,B,96,7)
DispGraph
RectI(0,B,96,7)
Repeat getKey
End
If (getKey(54)) or (getKey(9))
If B=21
If X
0->X
Else
1->X
End
Goto DSET2
End
If B=28
If Y
0->Y
Else
1->Y
End
Goto DSET2
End
If B=35
If Z
0->Z
Else
1->Z
End
Goto DSET2
End
If B=42
If sub(CODE)
DelVar Str1
Goto END
Else
Goto DSET2
End
End
End
If (getKey(4)) and (B!=21)
For(7)
RectI(0,B,96,7)
DispGraph
RectI(0,B,96,7)
B--
Normal
Pause 3
Full
End
End
If (getKey(1)) and (B!=42)
For(7)
RectI(0,B,96,7)
DispGraph
RectI(0,B,96,7)
B++
Normal
Pause 3
Full
End
End
If getKey(15)
If ({[Y1]+5}!=X) or ({[Y1]}!=Y) or ({[Y1]+6}!=Z)
UnArchive Str1
GetCalc(Str1)->S
X->{S+5}
Y->{S}
Z->{S+6}
sub(D3)
DispGraph
Archive Str1
GetCalc(Str1,[Y1])
End
Repeat getKey=0
End
Goto DLIST
End
Goto KSET
```
--------------------------------
### Now.json Build Configuration for @now/next
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Markdown/sample.mdx
Defines the build process in `now.json`, specifying the use of the `@now/next` builder for the `next.config.js` entrypoint.
```json
{
"version": 2,
"builds": [{ "src": "next.config.js", "use": "@now/next" }]
}
```
--------------------------------
### Conditional Jump Example: TRNN
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Trap if zero. Used for checking if a value is zero.
```assembly
TRNN
```
--------------------------------
### Check documentation coverage
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/RDoc/rdoc.rdoc
Commands to generate a documentation coverage report for a project.
```bash
rdoc -C lib
```
```bash
rdoc -C1 lib
```
--------------------------------
### Conditional Jump Example: AOS
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Add and skip if zero. Used for loop control and counting.
```assembly
AOS
```
--------------------------------
### Initialize and Fill Array
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/TI Program/srcsort.8xp.txt
Initializes an array L1 with a specified size and fills it with a given value. Used for setting up data structures.
```Assembly
Fill(L1,50,0)
```
--------------------------------
### Add Dependency
Source: https://github.com/monkslc/hyperpolyglot/blob/master/README.md
Include the library in your Cargo.toml file.
```TOML
[dependencies]
hyperpolyglot = "0.1.0"
```
--------------------------------
### Analyze Directories and Files via CLI
Source: https://context7.com/monkslc/hyperpolyglot/llms.txt
Various CLI commands for analyzing codebases, including directory scanning, file breakdowns, and strategy reporting.
```bash
# Analyze current directory
hyply
# Output:
# 85.00% Rust
# 15.00% RenderScript
```
```bash
# Analyze a specific directory
hyply /path/to/project
# Output:
# 72.50% JavaScript
# 15.30% TypeScript
# 8.20% CSS
# 4.00% HTML
```
```bash
# Show which language was detected for each file
hyply --breakdown /path/to/project
# Output:
# Rust (15)
# src/lib.rs
# src/bin/main.rs
# src/detectors/mod.rs
# ...
#
# JavaScript (8)
# frontend/app.js
# frontend/utils.js
# ...
```
```bash
# Show which detection strategy was used for each file
hyply --strategies /path/to/project
# Output:
# Extension (45)
# src/main.py (Python)
# src/utils.js (JavaScript)
# ...
#
# Heuristics (12)
# src/header.h (C)
# ...
#
# Classifier (3)
# config.rs (Rust)
# ...
```
```bash
# Show only headers (file counts) for specific languages
hyply --breakdown --condensed --filter "Rust|Python" /path/to/project
# Output:
# Rust (15)
# Python (8)
```
```bash
# Useful when piping output to other commands
hyply --no-color /path/to/project | grep "Rust"
```
--------------------------------
### Conditional Jump Example: TDNN
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Trap if digit zero. Used for specific digit-based comparisons.
```assembly
TDNN
```
--------------------------------
### Conditional Jump Example: TDNE
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Trap if digit non-zero. Used for specific digit-based comparisons.
```assembly
TDNE
```
--------------------------------
### Run Hyperpolyglot CLI
Source: https://github.com/monkslc/hyperpolyglot/blob/master/README.md
Execute the tool against a specific file or directory path.
```bash
hyply [PATH]
```
--------------------------------
### Create a Virtual Environment for SciPy Development
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/reStructuredText/HACKING.rst.txt
Set up a dedicated virtual environment for SciPy development using `virtualenv` and `virtualenvwrapper`. This isolates your development environment and prevents conflicts with other Python projects.
```bash
mkvirtualenv scipy-dev
```
--------------------------------
### Define Scalar Short Load/Store Instructions
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Instructions for handling 16-bit short data types.
```Lisp
(define_insn ""
[(set (subreg:QI
(zero_extract:SI (match_operand:SI 0 "memory_operand" "+m")
(const_int 9)
(const_int 27))
3)
(match_operand:QI 1 "register_operand" "r"))]
"MEM_SCALAR_P (operands[0])"
"movem %1,%0")
```
```Lisp
(define_insn ""
[(set (subreg:HI
(zero_extract:SI (match_operand:SI 0 "memory_operand" "+m")
(const_int 18)
(const_int 18))
2)
(match_operand:HI 1 "register_operand" "r"))]
"MEM_SCALAR_P (operands[0])"
"movem %1,%0")
```
```Lisp
(define_insn ""
[(set (match_operand:SI 0 "register_operand" "=r")
(zero_extend:SI
(match_operand:HI 1 "pdp10_maybe_volatile_memory_operand" "m")))]
"MEM_SCALAR_P (operands[1])"
"move %0,%W1")
```
```Lisp
(define_insn ""
[(set (match_operand:HI 0 "register_operand" "=r")
(subreg:HI
(zero_extract:SI
(match_operand:SI 1 "pdp10_maybe_volatile_memory_operand" "m")
(const_int 18)
(const_int 18))
2))]
"MEM_SCALAR_P (operands[1])"
"move %0,%W1")
```
--------------------------------
### Conditional Jump Example: CMPBP
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Compare byte pointer. Used for string manipulation and memory comparisons.
```assembly
CMPBP
```
--------------------------------
### Authentication and UI Routines
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/TI Program/srcfunc.8xp.txt
Subroutines for handling administrative access, drawing titles, and rendering window interfaces.
```Axe Parser
.FUNC AlphaCS
Lbl ADM
DiagnosticOff
Fix 5
Full
StoreGDB
sub(D2,13,17,70,29,"Admin Access")
sub(D1,15,27)
Text(15,37,"Admin Code: - - - -")
DispGraph
Repeat getKey->A
End
Text(55,37,"*")
DispGraph
Repeat getKey->B
End
Text(62,37,"*")
DispGraph
Repeat getKey->C
End
Text(69,37,"*")
DispGraph
Repeat getKey->D
End
Text(76,37,"*")
DispGraph
Normal
Pause 100
Full
If (A!=20) or (B!=35) or (C!=18) or (D!=27)
Goto END
End
sub(D2,13,17,70,29,"Author Info")
sub(D1,15,27)
Bitmap(15,38,GDB0)
DispGraph
Repeat (getKey) and (getKey(9))
End
DelVar "appv alpha "
Return
Lbl D1
.draws title
Pt-On([r1]+1,[r2]+1,Pic11)
Pt-On([r1]+10,[r2]+1,Pic12)
Pt-On([r1]+19,[r2]+1,Pic13)
Pt-On([r1]+28,[r2]+1,Pic14)
Pt-On([r1]+37,[r2]+1,Pic15)
Pt-On([r1]+48,[r2]+1,Pic16)
Pt-On([r1]+57,[r2]+1,Pic17)
RectI([r1],[r2],66,10)
Pxl-Off([r1],[r2])
RectI([r1]+14,[r2],4,5)
RectI([r1]+23,[r2]+7,4,3)
RectI([r1]+46,[r2]+1,1,8)
RectI([r1]+45,[r2],3,1)
RectI([r1]+46,[r2]+9,2,1)
Pxl-Off([r1]+65,[r2]+9)
Return
Lbl D2
.windows
Rect([r1]+1,[r2],[r3]-2,[r4])
Rect([r1],[r2]+1,[r3],[r4]-2)
RectI([r1]+1,[r2]+1,[r3]-2,[r4]-2)
Text([r1]+2,[r2]+2,[r5])
RectI([r1]+1,[r2]+1,[r3]-2,8)
Pt-Off([r1]+[r3]-9,[r2]+1,[C1BEAAB6AABEC1FF])
Pxl-On([r1]+1,[r2]+[r4]-2)
Pxl-On([r1]+[r3]-2,[r2]+[r4]-2)
Return
```
--------------------------------
### Conditional Jump Example: TRNE
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Trap if non-zero. Used for error checking or specific condition testing.
```assembly
TRNE
```
--------------------------------
### Generate documentation programmatically
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/RDoc/rdoc.rdoc
Use the RDoc library directly within a Ruby script to generate documentation.
```ruby
gem 'rdoc'
require 'rdoc/rdoc'
options = RDoc::Options.new
# see RDoc::Options
rdoc = RDoc::RDoc.new
rdoc.document options
# see RDoc::RDoc
```
--------------------------------
### Clone SciPy Repository and Perform In-Place Build
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/reStructuredText/HACKING.rst.txt
Clone the SciPy repository and set up an in-place build for immediate testing and development. This method allows you to edit Python source files and test changes by restarting the interpreter.
```bash
git clone https://github.com/scipy/scipy.git scipy
cd scipy
python setup.py build_ext -i
```
--------------------------------
### Pointer Arithmetic Example: IBP
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Increments a pointer by a specified value. Used for advancing pointers in memory.
```assembly
IBP
```
--------------------------------
### Logical Operations Example: ORCAI
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Performs a bitwise OR with the complement of an immediate value. Useful for setting bits.
```assembly
ORCAI
```
--------------------------------
### Define Byte Store Instructions
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Patterns for storing bytes into memory using pdp10_output_store_byte.
```Lisp
(define_insn "*DPBqi"
[(set (match_operand:QI 0 "memory_operand" "=>,m")
(match_operand:QI 1 "register_operand" "r,r"))]
""
"*return pdp10_output_store_byte (insn, operands);"
[(set_attr "reorg_type" "none,dpb")])
```
```Lisp
(define_insn "*DPBIqi"
[(set (match_operand:QI 0 "memory_operand" "=<")
(match_operand:QI 1 "register_operand" "r"))]
"TARGET_XKL2"
"*return pdp10_output_store_byte (insn, operands);")
```
--------------------------------
### Logical Operations Example: ANDCAI
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Performs a bitwise AND with the complement of an immediate value. Useful for clearing bits.
```assembly
ANDCAI
```
--------------------------------
### Define Unsigned Division and Modulo Instructions
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Instruction patterns for unsigned division and modulo on the XKL2 target.
```Lisp
(define_insn "udivsi3"
[(set (match_operand:SI 0 "reg_or_mem_operand" "=r,r,r,m")
(udiv:SI (match_operand:SI 1 "register_operand" "0,0,0,r")
(match_operand:SI 2 "general_operand" "I,i,rm,0")))]
"TARGET_XKL2"
"@
extend %0,[uidivi %2]
extend %0,[uidiv [%2]]
extend %0,[uidiv %2]
extend %1,[uidivm %0]")
```
```Lisp
(define_insn "umodsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,m")
(umod:SI (match_operand:SI 1 "register_operand" "0,0,0,r")
(match_operand:SI 2 "general_operand" "I,i,rm,0")))]
"TARGET_XKL2"
"@
extend %0,[uimodi %2]
extend %0,[uimod [%2]]
extend %0,[uimod %2]
extend %1,[uimodm %0]")
```
--------------------------------
### Next.js Serverless Target Configuration
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Markdown/sample.mdx
This configuration within `next.config.js` instructs Next.js to build each page as a separate serverless lambda function.
```js
module.exports = {
target: "serverless"
}
```
--------------------------------
### Unconditional Jump Example: JRST
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Jump and store return address. Used for subroutine calls or simple jumps.
```assembly
JRST
```
--------------------------------
### EQV and EQVI Instruction Patterns
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Patterns for equivalence (XNOR) operations.
```Lisp
(define_insn "*EQV"
[(set (match_operand:SI 0 "reg_or_mem_operand" "=r,m")
(not:SI (xor:SI (match_operand:SI 1 "reg_or_mem_operand" "%0,0")
(match_operand:SI 2 "reg_or_mem_operand" "rm,r"))))]
""
"@
eqv %0,%2
eqvm %2,%0")
```
```Lisp
(define_insn "*EQVI_reg"
[(set (match_operand:SI 0 "register_operand" "=r")
(not:SI (xor:SI (and:SI (match_operand:SI 1 "register_operand" "x")
(const_int RIGHT_HALF))
(match_operand:SI 2 "register_operand" "0"))))]
""
"eqvi %0,(%1)")
```
```Lisp
(define_insn "*EQVI_const_plus_reg"
[(set (match_operand:SI 0 "register_operand" "=r")
(not:SI (xor:SI (and:SI (plus:SI
(match_operand:SI 1 "register_operand" "x")
(match_operand:SI 2 "const_int_operand" "I"))
(const_int RIGHT_HALF))
(match_operand:SI 3 "register_operand" "0"))))]
"pdp10_const_ok_for_letter_p (INTVAL (operands[2]), 'I')"
"eqvi %0,%2(%1)")
```
--------------------------------
### Logical Operations Example: ORCMI
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Performs a bitwise OR with a complemented immediate value. Used for setting specific bits.
```assembly
ORCMI
```
--------------------------------
### Define ashldi3 expansion and instructions
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Expansion and instruction patterns for 64-bit left shifts.
```Lisp
(define_expand "ashldi3"
[(set (match_operand:DI 0 "register_operand" "")
(ashift:DI (match_operand:DI 1 "register_operand" "")
(match_operand:SI 2 "general_operand" "")))]
""
"")
```
```Lisp
(define_insn "*ashldi3"
[(set (match_operand:DI 0 "register_operand" "=r,r,r")
(ashift:DI (match_operand:DI 1 "register_operand" "0,0,0")
(match_operand:SI 2 "general_operand" "x,K,m")))]
"!TARGET_71BIT"
"@
lshc %0,(%2)
lshc %0,%2
lshc %0,@%2")
```
```Lisp
(define_insn "LSHC_left"
[(set (match_operand:DI 0 "register_operand" "=r,r,r")
(unspec:DI [(match_operand:DI 1 "register_operand" "0,0,0")
(match_operand:SI 2 "general_operand" "x,K,m")]
UNSPEC_LSHC))]
"TARGET_71BIT"
"@
lshc %0,(%2)
lshc %0,%2
lshc %0,@%2")
```
```Lisp
(define_insn "*ashldi3_71bit"
[(set (match_operand:DI 0 "register_operand" "=r,r,r")
(ashift:DI (match_operand:DI 1 "register_operand" "0,0,0")
(match_operand:SI 2 "general_operand" "x,K,m")))]
"TARGET_71BIT"
{
const char *asms[] =
{
"lsh %Z0,1\;lshc %0,(%2)\;lsh %Z0,-1",
"lsh %Z0,1\;lshc %0,%2\;lsh %Z0,-1",
"lsh %Z0,1\;lshc %0,@%2\;lsh %Z0,-1"
};
switch (get_attr_length (insn))
{
case 3:
operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
output_asm_insn ("lshc %0,%2", operands);
break;
case 4:
{
static char insn[100];
int n = INTVAL (operands[2]);
snprintf (insn, sizeof insn,
n < 18 ? "tlne %%0,%o" : "trne %%0,%o",
0400000 >> (n < 18 ? n: n - 18));
output_asm_insn (insn, operands);
return "%_tloa %0,400000\;%_%_tlz %0,400000\;ashc %0,%2";
}
case 5:
output_asm_insn (asms[which_alternative], operands);
break;
default:
abort ();
}
return "tlne %0,400000\;%_tlo %Z0,400000";
}
[(set (attr "length")
(if_then_else (match_operand 2 "const_int_operand" "")
(if_then_else
(ge (symbol_ref "INTVAL (operands[2])") (const_int 36))
(const_int 3)
(const_int 4))
(const_int 5)))])
```
--------------------------------
### Conditional Jump Example: TLZN
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Trap if less than zero. Used for range checks or specific bit pattern comparisons.
```assembly
TLZN
```
--------------------------------
### Configure Next.js for Serverless Target
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Markdown/sample.mdx
Sets the Next.js build target to 'serverless', enabling the creation of individual lambda functions for each page.
```js
module.exports = {
target: 'serverless'
}
```
--------------------------------
### Conditional Jump Example: TLNN
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Trap if less than zero. Used for range checks or specific bit pattern comparisons.
```assembly
TLNN
```
--------------------------------
### Conditional Jump Example: TLNE
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Trap if less than non-zero. Used for range checks or specific bit pattern comparisons.
```assembly
TLNE
```
--------------------------------
### Unconditional Jump Example: JFCL
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Jump if condition is met. Often used for checking flags or status bits before branching.
```assembly
JFCL
```
--------------------------------
### Load and Plot Image
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Jupyter Notebook/JupyterNotebook.ipynb
Loads an image using scipy.ndimage and displays it. Requires matplotlib for plotting.
```python
import scipy.ndimage
%matplotlib inline
import matplotlib.pyplot as plt
import numpy
def plotImage(image, cmap='gray'):
birdsPlot = plt.imshow(image, cmap=cmap)
birdsPlot.axes.get_xaxis().set_visible(False)
birdsPlot.axes.get_yaxis().set_visible(False)
plt.show()
birdsOriginal = scipy.ndimage.imread("images/birds.jpg")
print("Original image:")
plotImage(birdsOriginal)
```
--------------------------------
### Logical Operations Example: ANDCMI
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Performs a bitwise AND operation with a complemented immediate value. Used for clearing specific bits.
```assembly
ANDCMI
```
--------------------------------
### One's Complement and SETC Patterns
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/GCC Machine Description/pdp10.md
Patterns for one's complement and SETC instructions.
```Lisp
(define_insn "one_cmplsi2"
[(set (match_operand:SI 0 "reg_or_mem_operand" "=r,r,m,m")
(not:SI (match_operand:SI 1 "reg_or_mem_operand" "0,rm,r,0")))]
""
"@
setca %0,
setcm %0,%1
setcam %1,%0
setcmm %0")
```
```Lisp
(define_insn "*SETCAB"
[(set (match_operand:SI 0 "memory_operand" "+m")
(not:SI (match_operand:SI 1 "register_operand" "r")))
(set (match_operand:SI 2 "register_operand" "=1")
(not:SI (match_dup 1)))]
""
"setcab %1,%0")
```
```Lisp
(define_insn "*SETCMB"
[(set (match_operand:SI 0 "memory_operand" "+m")
(not:SI (match_dup 0)))
(set (match_operand:SI 1 "register_operand" "=r")
(not:SI (match_dup 0)))]
""
"setcmb %0,%1")
```
--------------------------------
### Add Library Dependency
Source: https://context7.com/monkslc/hyperpolyglot/llms.txt
Include hyperpolyglot as a dependency in your Cargo.toml file.
```toml
[dependencies]
hyperpolyglot = "0.1.7"
```
--------------------------------
### Convert org-mode to HTML in Ruby
Source: https://github.com/monkslc/hyperpolyglot/blob/master/samples/Org/org.org
Basic usage of the Orgmode::Parser to read a file and output its HTML representation.
```ruby
require 'rubygems'
require 'org-ruby'
data = IO.read(filename)
puts Orgmode::Parser.new(data).to_html
```
--------------------------------
### Get Language Metadata
Source: https://context7.com/monkslc/hyperpolyglot/llms.txt
Retrieve metadata for a given language name, including its type, GitHub color, and parent group. Can also filter language names by type.
```rust
use std::convert::TryFrom;
use hyperpolyglot::{Language, LanguageType};
fn main() {
// Get language info from name
let rust = Language::try_from("Rust").unwrap();
println!("Name: {}", rust.name); // "Rust"
println!("Type: {}", rust.language_type); // "Programming"
println!("Color: {:?}", rust.color); // Some("#dea584")
println!("Group: {:?}", rust.group); // None
// TypeScript is grouped under JavaScript parent
let tsx = Language::try_from("TSX").unwrap();
assert_eq!(tsx.group, Some("TypeScript"));
// Filter results by language type
let language_names = vec!["Rust", "JSON", "Markdown", "Python"];
let programming_only: Vec<&str> = language_names
.iter()
.filter_map(|name| Language::try_from(*name).ok())
.filter(|lang| lang.language_type == LanguageType::Programming)
.map(|lang| lang.name)
.collect();
println!("Programming languages: {:?}", programming_only);
// Output: ["Rust", "Python"]
}
```