Skip to content

Commit

Permalink
reverted the revert
Browse files Browse the repository at this point in the history
  • Loading branch information
aName2050 authored May 23, 2024
1 parent 6ecd2c1 commit dec2b88
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/GigaScript/gsx.tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ setTokenData(TokenID.Export, NodeType.Export, 'yeet', OpPrec.None);
setTokenData(TokenID.From, NodeType.From, 'from', OpPrec.None);
setTokenData(TokenID.As, NodeType.As, 'as', OpPrec.Assignment);

setTokenData(TokenID.Throw, NodeType.Throw, 'shoot', OpPrec.None);
setTokenData(TokenID.Throw, NodeType.Throw, 'uhhh', OpPrec.None);

setTokenData(TokenID.Try, NodeType.Try, 'messAround', OpPrec.None);
setTokenData(TokenID.Catch, NodeType.Catch, 'findOut', OpPrec.None);
Expand Down Expand Up @@ -153,6 +153,8 @@ setTokenData(
setTokenData(TokenID.Semicolon, NodeType.Semicolon, 'rn', OpPrec.None);
setTokenData(TokenID.Colon, NodeType.Colon, 'is', OpPrec.None);
setTokenData(TokenID.Dot, NodeType.Dot, '.', OpPrec.None);
// comma can be "," or "and"
setTokenData(TokenID.Comma, NodeType.Comma, 'and', OpPrec.None);
setTokenData(TokenID.Comma, NodeType.Comma, ',', OpPrec.None);

// [assignments]
Expand Down
16 changes: 12 additions & 4 deletions src/GigaScript/runtime/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,24 @@ export function createGlobalScope(cwd: string): Environment {
env.declareVar(isGSXFile ? 'whoops' : 'error', NativeValues.Error, true);

// Native functions
env.declareVar(isGSXFile ? 'yap' : 'print', NativeFunctions.print, true);
env.declareVar(
'generateTimestamp',
isGSXFile ? 'HelloWorld' : 'print',
NativeFunctions.print,
true
);
env.declareVar(
isGSXFile ? 'theCurrentTimeAtThisVeryMoment' : 'generateTimestamp',
NativeFunctions.generateTimestamp,
true
);
env.declareVar(isGSXFile ? 'nerd' : 'math', NativeFunctions.math, true);
env.declareVar('formatString', NativeFunctions.formatString, true);
env.declareVar(
isGSXFile ? 'lockIn' : 'formatString',
NativeFunctions.formatString,
true
);
env.declareVar('Array', NativeFunctions.Array, true);
env.declareVar('GSON', NativeFunctions.GSON, true);
env.declareVar(isGSXFile ? 'GigaSON' : 'GSON', NativeFunctions.GSON, true);

return env;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/test.gsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
lit truthy be nocap rn
lit falsey be cap rn

yap(truthy)
yap(falsey)
HelloWorld(truthy)
HelloWorld(falsey)

"shoot 'error!!'"

yap(nerd.random(1, 10))
HelloWorld(nerd.random(1, 10))

bro object be {
x is 32,
truthy,
x is 32 and
truthy and
complex is {
more is 'hello'
}
} rn

yap(object)
HelloWorld(object)

0 comments on commit dec2b88

Please sign in to comment.