HydraScript 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global HydraScript --version 1.0.2
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local HydraScript --version 1.0.2
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=HydraScript&version=1.0.2
                    
nuke :add-package HydraScript --version 1.0.2
                    

Code Coverage

Package Line Rate Health
Interpreter 68%
Interpreter.Lib 26%
Summary 30% (754 / 2527)

Minimum allowed line rate is 20%

Дипломная работа

"Расширенное подмножество ЯП JavaScript"

Вводная информация

За основу был взят стандарт ECMA-262

Лексическая структура

Грамматика

Рабочие примеры

Конструкции языка

Типизация

В языке структурная статическая сильная типизация.

Есть 5 примитивных типов:

  1. number
  2. boolean
  3. string
  4. null
  5. void

Остальные типы делятся на группы:

  • NullableType (тип, который допускает значение null)
  • ObjectType (тип объекта, является NullableType)
  • ArrayType (списковый тип)
  • FunctionType (тип функции)
Значения по умолчанию
Тип Значение
number 0
boolean false
string ""
NullableType null
ArrayType []
type alias

Можно создать свой type alias по типу того, как это сделано в С++

type int = number
type maybeInt = int?
type ints = int[]
type point = {
    x: int;
    y: int;
}
type handleInts = (ints) => void
type handler = {
    items: ints;
    handle: handleInts;
}
Объявление переменных
let i = 1 // интерпретатор выведет тип из выражения
let j: number // запишет значение по умолчанию в переменную
let k: number = 1 // полностью явное объявление
Объекты
let v2d = {
    // обычное поле
    x: 3;
    y: 4;
    //метод
    lengthSquared => () {
        // в методе доступны поля объекта
        // и указатель this
        return x * x + y * y
    };
}
Списки
let array = [1, 2, 3]
let size = ~array // длина списка
array::1 // удаление элемента по индексу
array = array ++ [5, 7] // конкатенация списков
Операторы
Оператор Вид Типы операндов Тип операции
+ бинарный оба number, оба string number, string
*, -, /, % бинарный number number
||, && бинарный boolean boolean
!=, == бинарный равный с двух сторон boolean
<=, >=, >, < бинарный number boolean
! унарный boolean boolean
- унарный number number
++ бинарный [] []
:: бинарный [] и number void
~ унарный [] number
Ветвление
if (1 == 1) {
    // ...
} else if (2 == 2) {
    // ...
}
else {
    // ...
}
// в общем как в Си подобных языках
// главное, чтобы выражение условия
// возвращало boolean

Также есть тернарный оператор

let x = 1 > 0 ? 0 <= 1 ? 1 : 0 : -2 < 0 ? -1 : 0
Цикл
while (cond) {
    // ...
    continue
    // ...
    break
}
Функции
// объявление
function add(a: number, b: number): number {
    return a + b
}
// вызов
let c = add(1, 2)
Операции доступа
// объекты
let x = v2d.x
let s = v2d.lengthSquared()
// массивы
let l = array[2]
Приведение типов
let s = v2d as string
Стандартная библиотека
  • Функция print c сигнатурой (string) => void; осуществляет печать строки на экран

Требования

  • .NET 5 SDK

Сборка

После клонирования репозитория идём в папку проекта Interpreter.

Там выполняем команду: dotnet publish -r <RUNTIME_IDENTIFIER> -p:PublishSingleFile=true -p:DebugType=embedded --self-contained false -o <OUTPUT_DIRECTORY>

Список идентификаторов рантайма лежит тут

Запуск

Interpreter 1.0.0
Copyright (C) 2022 Interpreter
USAGE:
Simple interpretation call:
  Interpreter file.js
Request dump:
  Interpreter --dump file.js

  -d, --dump                (Default: false) Show dump data of interpreter

  --help                    Display this help screen.

  --version                 Display version information.

  InputFilePath (pos. 0)    Required. Path to input file

Источники:

  1. ECMA-262
  2. DragonBook
  3. Stanford CS143 Lectures
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
2.6.1 87 1/2/2026
2.6.0 124 12/26/2025
2.5.1 171 12/23/2025
2.5.0 164 12/23/2025
2.4.0 174 12/23/2025
2.3.0 171 12/23/2025
2.2.0 168 12/23/2025
2.1.1 166 12/23/2025
2.1.0 171 12/23/2025
2.0.0 168 12/23/2025
1.2.6 166 12/23/2025
1.2.5 168 12/23/2025
1.1.5 166 12/23/2025
1.1.4 163 12/23/2025
1.1.3 172 12/23/2025
1.1.2 168 12/23/2025
1.0.2 176 12/23/2025
1.0.0 171 12/23/2025