New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

algo-lang

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

algo-lang - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

18

build/visitors/typer.js

@@ -238,8 +238,11 @@ 'use strict';

if (!(array.array.resType instanceof ast.Array)) throw new _error.JungleError('Impossible d\'utiliser l\'opérateur [] sur une expression qui n\'est pas un tableau (type ' + array.arrayType.name + ')');
const isArray = array.array.resType instanceof ast.Array;
const isChaine = array.array.resType instanceof types.Chaine;
if (array.positions.length != array.array.resType.dimensions.length) throw new _error.JungleError('Impossible d\'accéder à un tableau de type ' + array.array.resType.name + ' en utilisant ' + array.positions.length + ' dimensions alors qu\'il en comporte ' + array.array.resType.dimensions.length);
if (!isArray && !isChaine) throw new _error.JungleError('Impossible d\'utiliser l\'opérateur [] sur une expression qui n\'est pas un tableau ou une chaine (type ' + array.arrayType.name + ')');
array.resType = array.array.resType.type;
if (isArray && array.positions.length != array.array.resType.dimensions.length) throw new _error.JungleError('Impossible d\'accéder à un tableau de type ' + array.array.resType.name + ' en utilisant ' + array.positions.length + ' dimensions alors qu\'il en comporte ' + array.array.resType.dimensions.length);else if (isChaine && array.positions.length != 1) throw new _error.JungleError('Impossible d\'accéder à une chaine en utilisant ' + array.positions.length + ' dimensions');
array.resType = isArray ? array.array.resType.type : this.scopes.getType('caractere');
array.positions.forEach((pos, i) => {

@@ -249,3 +252,3 @@ if (pos.resType !== this.scopes.getType('entier')) throw new _error.JungleError('Le type de l\'expression pour la dimension ' + (i + 1) + ' lors de l\'accès à un tableau de type ' + array.resType.name + ' doit être un entier et non un ' + pos.resType.name);

array.writable = true;
array.writable = isArray;
}

@@ -333,3 +336,7 @@

case '=':
if (binary.left.resType instanceof ast.Enum && binary.left.resType === binary.right.resType) {
case '<>':
const isEnum = binary.left.resType instanceof ast.Enum;
const isPointer = binary.left.resType instanceof ast.Pointer;
const sameTypes = binary.left.resType === binary.right.resType;
if (isEnum && sameTypes || isPointer && (sameTypes || binary.left.resType instanceof types.NulPointer || binary.right.resType instanceof types.NulPointer)) {
binary.resType = this.scopes.getType('booleen');

@@ -342,3 +349,2 @@ return;

case '>=':
case '<>':
choice = 'cmp';

@@ -345,0 +351,0 @@ break;

@@ -240,10 +240,15 @@ import {EmptyVisitor} from './empty.js'

if (!(array.array.resType instanceof ast.Array))
throw new JungleError('Impossible d\'utiliser l\'opérateur [] sur une expression qui n\'est pas un tableau (type ' + array.arrayType.name + ')')
const isArray = array.array.resType instanceof ast.Array
const isChaine = array.array.resType instanceof types.Chaine
if (array.positions.length != array.array.resType.dimensions.length)
if (!isArray && !isChaine)
throw new JungleError('Impossible d\'utiliser l\'opérateur [] sur une expression qui n\'est pas un tableau ou une chaine (type ' + array.arrayType.name + ')')
if (isArray && array.positions.length != array.array.resType.dimensions.length)
throw new JungleError('Impossible d\'accéder à un tableau de type ' + array.array.resType.name + ' en utilisant ' +
array.positions.length + ' dimensions alors qu\'il en comporte ' + array.array.resType.dimensions.length)
else if (isChaine && array.positions.length != 1)
throw new JungleError('Impossible d\'accéder à une chaine en utilisant ' + array.positions.length + ' dimensions')
array.resType = array.array.resType.type
array.resType = isArray ? array.array.resType.type : this.scopes.getType('caractere')

@@ -256,3 +261,3 @@ array.positions.forEach((pos, i) => {

array.writable = true
array.writable = isArray
}

@@ -348,3 +353,10 @@

case '=':
if (binary.left.resType instanceof ast.Enum && binary.left.resType === binary.right.resType) {
case '<>':
const isEnum = binary.left.resType instanceof ast.Enum
const isPointer = binary.left.resType instanceof ast.Pointer
const sameTypes = binary.left.resType === binary.right.resType
if ((isEnum && sameTypes) ||
(isPointer && (sameTypes ||
binary.left.resType instanceof types.NulPointer ||
binary.right.resType instanceof types.NulPointer))) {
binary.resType = this.scopes.getType('booleen')

@@ -357,3 +369,2 @@ return

case '>=':
case '<>':
choice = 'cmp'

@@ -360,0 +371,0 @@ break

{
"name": "algo-lang",
"version": "1.0.4",
"version": "1.0.5",
"description": "Algorithmic language interpreter (in French only for now)",

@@ -5,0 +5,0 @@ "homepage": "https://bitbucket.org/lsystems/algo-lang/overview",

@@ -58,1 +58,45 @@ # Algorithmic natural language interpreter (language using french keywords)

[Documentation in french](http://algo.infoprepa.epita.fr/index.php/Epita:Algo:Mémo-Langage)
### Good to know
#### Operator aliases
Some operators have aliases to ease development:
* `<-` is equivalent to `←`
* `^` is equivalent to `↑`
#### `nul`
There is a special `nul` keyword to assign the null pointer to any pointer variable and check if a pointer is null.
#### Available types
Only those base types are available:
* `caractere` (can be cast with system routines to: `chaine`, `entier`)
* `chaine` (can be cast with system routines to: `entier`, `reel`)
* `entier` (can be cast with system routines to: `caractere`, `chaine`, `reel`)
* `reel` (can be cast with system routines to: `chaine`, `entier`)
#### System routines
There are some system routines you can use:
* `afficher(chaine)`: prints the string on stdout (no endline is added automatically)
* `allouer(pointer)`: allocate memory for the pointed value
* `caractere(value)`: try to cast `value` in `caractere`
* `chaine(value)`: try to cast `value` in `chaine`
* `entier(value)`: try to cast `entier` in `chaine`
* `liberer(pointer)`: free memory pointed by the provided pointer, do nothing if pointer is `nul`, resets `pointer` to `nul`
* `longueur(chaine)`: returns the length of the string
#### Operator `[]`
The operator also allows you to access characters (`caractere`) in a string (`chaine`) like in:
```
afficher("toto"[1])
```
**Important note:** In this language, index are from `1` to `n` and not from `0` to `n − 1`!

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc