Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language server #31

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion .vscode/launch.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
Expand All @@ -13,6 +13,46 @@
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
},
{
"name": "Attach to Language Server",
"type": "pwa-node",
"port": 6009,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/**/*.js",
]
},
{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
},
{
"name": "Debug Jest Watch",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand",
"--watch"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
]
}
80 changes: 80 additions & 0 deletions builtin/functions.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Mathematical cosine function
function cos(degrees)=0;

// Mathematical sine function.
function sin(degrees)=0;

// Mathematical tangent function.
function tan(degrees)=0;

// Mathematical arccosine, or inverse cosine, expressed in degrees.
function acos(value)=0;

// Mathematical arcsine, or inverse sine, expressed in degrees.
function asin(value)=0;

// Mathematical arctangent, or inverse tangent, function. Returns the principal value of the arc tangent of x, expressed in degrees.
function atan(value)=0;

// Mathematical two-argument atan function atan2(y,x) that spans the full 360 degrees.
// This function returns the full angle (0-360) made between the x axis and the vector(x,y)
// expressed in degrees. atan can not distinguish between y/x and -y/-x and returns angles from -90 to +90
function atan2(y,x)=0;

// Mathematical absolute value function. Returns the positive value of a signed decimal number.
function abs(value)=0;

// Mathematical ceiling function.
// Returns the next highest integer value by rounding up value if necessary.
function ceil(value)=0;

// Return a new vector that is the result of appending the elements of the supplied vectors.
function concat(values)=0; //varargs

// Calculates the cross product of two vectors in 3D or 2D space.
function cross(value)=0;

// Mathematical exp function. Returns the base-e exponential function of x, which is the number e raised to the power x.
function exp(value)=0;


// Mathematical floor function. floor(x) = is the largest integer not greater than x
function floor(value)=0;

// Mathematical natural logarithm.
function ln(value)=0;

// Mathematical length function. Returns the length of an array, a vector or a string parameter.
function len(value)=0;

// let(): this is built into the grammar

// Mathematical logarithm to the base 10. Example: log(1000) = 3.
function log(value)=0;

// Look up value in table, and linearly interpolate if there's no exact match. The first argument is the value to look up. The second is the lookup table -- a vector of key-value pairs.
function lookup(p,table)=0;

// Returns the maximum of the parameters. If a single vector is given as parameter, returns the maximum element of that vector.
function max(n)=0; // varargs

// Returns the minimum of the parameters. If a single vector is given as parameter, returns the minimum element of that vector.
function min(value)=0; // varargs

// Returns the euclidean norm of a vector.
function norm(value)=0;

// Mathematical power function. As of version 2021.01 you can use the exponentiation operator ^ instead.
function pow(value)=0;

// Random number generator. Generates a constant vector of pseudo random numbers, much like an array. The numbers are doubles not integers.
function rand(min_value, max_value, value_count, seed_value)=0;

// The "round" operator returns the greatest or least integer part, respectively, if the numeric input is positive or negative.
function round(value)=0;

// Mathematical signum function. Returns a unit value that extracts the sign of a value
function sign(value)=0;

// Mathematical square root function.
function sqrt(value)=0;
31 changes: 31 additions & 0 deletions builtin/modules.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module cube(size, center=false){}
module sphere(r=0, d=0, $fa=0,$fs=0, $fn=0){}
module cylinder($fn = 0, $fa = 12, $fs = 2, h = 1, r1 = 1, r2 = 1, center = false, d1=2, d2=2, r=1, d=1){}
module polyhedron(points=undef, faces=undef, triangles=undef, convexity=1){}

module square(size=[1,1], center=false){};
module circle($fn = 0, $fa = 12, $fs = 2, r = 1){}
module polygon(points = undef, paths = undef, convexity = 1){}
module import_dxf(file, layer){}
module import(file, convexity=undef, layer=undef, origin=undef, $fn=undef, $fa=undef, $fs=undef){}
module text(test, size=undef, font=undef, halign=undef, valign=undef, spacing=undef, direction=undef, language=undef, script=undef, $fn=undef){}
module projection(cut=false){}
module linear_extrude(height = undef, center = false, convexity = undef, twist = undef, $fn = undef, scale=undef){}
module rotate_extrude(convexity=undef, angle=undef, $fa=undef, $fs=undef, $fn=undef){}

module scale(v){}
module resize(newsize, auto=undef){}
module rotate(a, v=undef){}
module translate(v){}
module mirror(v){}
module multmatrix(m){}
module color(c, alpha=1.0){}
module offset(r=undef, delta=undef, chamfer=undef){}
module minkowski(){}
module hull(){}

// boolean combinations
module union(){}
module difference(){}
module intersection(){}
module render(convexity=1){}
13 changes: 13 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"preset": "ts-jest",
"roots": [
"<rootDir>/test"
],
"collectCoverageFrom": [
"packages/langium/src/**/{!(generated),}/*"
],
"testEnvironment": "node",
"snapshotFormat": {
"maxDepth": 1
}
}
13 changes: 13 additions & 0 deletions langium-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"projectName": "Scad",
"languages": [
{
"id": "scad",
"grammar": "src/language-server/scad.langium",
"fileExtensions": [
".scad"
]
}
],
"out": "src/language-server/generated"
}
Loading