Skip to content

Commit

Permalink
feat(editors,tests): utilize struct keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
JaDogg committed Jun 24, 2023
1 parent a2cf8c2 commit 91b0394
Show file tree
Hide file tree
Showing 12 changed files with 460 additions and 392 deletions.
7 changes: 6 additions & 1 deletion compiler/test_data/compiler_tests/on_stack_test.yaka
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ class Enemy:
y: int
hp: int

struct Friend:
x: int

def main() -> int:
enemies: Array[Enemy] = arrnew("Enemy", 2)
enemies[0].x = 1
enemies[1].x = 2
good_person: Friend
good_person.x = 0
big_enemy: Enemy
big_enemy.x = 4
println(enemies[0].x + enemies[1].x + big_enemy.x)
println(enemies[0].x + enemies[1].x + big_enemy.x + good_person.x)
return 0
370 changes: 202 additions & 168 deletions compiler/test_data/compiler_tests/output/on_stack_test.tokens

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
#include "yk__lib.h"
// --forward declarations--
struct yy__Enemy;
struct yy__Friend;
int32_t yy__main();
// --structs--
struct yy__Enemy {
int32_t yy__x;
int32_t yy__y;
int32_t yy__hp;
};
struct yy__Friend {
int32_t yy__x;
};
// --functions--
int32_t yy__main()
{
Expand All @@ -17,9 +21,11 @@ int32_t yy__main()
struct yy__Enemy* yy__enemies = t__0;
yy__enemies[INT32_C(0)].yy__x = INT32_C(1);
yy__enemies[INT32_C(1)].yy__x = INT32_C(2);
struct yy__Friend yy__good_person;
yy__good_person.yy__x = INT32_C(0);
struct yy__Enemy yy__big_enemy;
yy__big_enemy.yy__x = INT32_C(4);
yk__printlnint(((intmax_t)((yy__enemies[INT32_C(0)].yy__x + yy__enemies[INT32_C(1)].yy__x) + yy__big_enemy.yy__x)));
yk__printlnint(((intmax_t)(((yy__enemies[INT32_C(0)].yy__x + yy__enemies[INT32_C(1)].yy__x) + yy__big_enemy.yy__x) + yy__good_person.yy__x)));
return INT32_C(0);
}
#if defined(YK__MINIMAL_MAIN)
Expand Down
2 changes: 1 addition & 1 deletion editor/intellij/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pluginGroup = com.github.jadogg.yakshaintellij
pluginName = YakshaIntelliJ
# SemVer format -> https://semver.org
pluginVersion = 0.0.8
pluginVersion = 0.0.9

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 213
Expand Down
427 changes: 218 additions & 209 deletions editor/intellij/src/main/gen/org/intellij/sdk/language/YakshaLexer.java

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}

yakshaFile ::= item_* {pin=1 recoverWhile="top_level_recover" name="import, def, class"}
private top_level_recover ::= !('@' | 'class' | 'def' | 'import' | 'runtimefeature')
private top_level_recover ::= !('@' | 'class' | 'struct' | 'def' | 'import' | 'runtimefeature')

private item_ ::= (outer_statement | COMMENT | empty_line)

Expand All @@ -39,7 +39,7 @@ const_statement ::= IDENTIFIER S? OPERATOR_COLON S? data_type S? OPERATOR_EQ S?
}
literal ::= NUMBER | KW_TRUE | KW_FALSE

class_statement ::= KW_CLASS S IDENTIFIER S? OPERATOR_COLON S? class_block {
class_statement ::= (KW_CLASS | KW_STRUCT) S IDENTIFIER S? OPERATOR_COLON S? class_block {
mixin="org.intellij.sdk.language.psi.impl.YakshaNamedElementImpl"
implements="org.intellij.sdk.language.psi.YakshaNamedElement"
methods=[getName setName getNameIdentifier getPresentation]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ TRIPLE_APOS_LITERAL = {THREE_APOS} {APOS_STRING_CHAR}* {THREE_APOS}?
"as" { return YakshaTypes.KW_AS; }
"break" { return YakshaTypes.KW_BREAK; }
"class" { return YakshaTypes.KW_CLASS; }
"struct" { return YakshaTypes.KW_STRUCT; }
"ccode" { return YakshaTypes.KW_CCODE; }
"continue" { return YakshaTypes.KW_CONTINUE; }
"def" { return YakshaTypes.KW_DEF; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class YakshaSyntaxHighlighter extends SyntaxHighlighterBase {
.add(YakshaTypes.KW_AS)
.add(YakshaTypes.KW_BREAK)
.add(YakshaTypes.KW_CLASS)
.add(YakshaTypes.KW_STRUCT)
.add(YakshaTypes.KW_CCODE)
.add(YakshaTypes.KW_CONTINUE)
.add(YakshaTypes.KW_DEF)
Expand Down
2 changes: 1 addition & 1 deletion editor/notepadplusplus/yaksha.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Keywords name="Folders in comment, open"></Keywords>
<Keywords name="Folders in comment, middle"></Keywords>
<Keywords name="Folders in comment, close"></Keywords>
<Keywords name="Keywords1">while def import continue break if elif else class return ccode pass defer del as for in</Keywords>
<Keywords name="Keywords1">while def import continue break if elif else class struct return ccode pass defer del as for in</Keywords>
<Keywords name="Keywords2">@nativedefine @varargs @onstack @nativemacro @native</Keywords>
<Keywords name="Keywords3">int float i8 i16 i32 i64 u8 u16 u32 u64 float f32 f64 Array Function In Const AnyPtr Out SMEntry MEntry str bool Ptr Tuple AnyPtrToConst</Keywords>
<Keywords name="Keywords4">print println len arrput arrpop arrnew array getref unref charat shnew shput shget shgeti hmnew hmput hmget hmgeti cast qsort iif foreach countif filter map binarydata arrsetlen arrsetcap</Keywords>
Expand Down
4 changes: 2 additions & 2 deletions editor/vscode/syntaxes/yaksha.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
{
"name": "keyword.language.yaksha",
"match": "\\b(while|def|import|continue|break|if|elif|else|class|return|pass|as|for|in)\\b"
"match": "\\b(while|def|import|continue|break|if|elif|else|class|struct|return|pass|as|for|in)\\b"
},
{
"name": "invalid.spaces.yaksha",
Expand Down Expand Up @@ -64,7 +64,7 @@
"match": "\\.|\\+|\\-|\\*|\\\/|\\:|\\[|\\]|\\(|\\)|,|>|<|<\\=|>\\=|\\=\\=|\\=|\\bnot\\b|\\bor\\b|\\band\\b|!\\=|\\->"
},
{
"match": "^(class)\\s+([a-zA-Z_][a-zA-Z0-9_]+)\\s*",
"match": "^(class|struct)\\s+([a-zA-Z_][a-zA-Z0-9_]+)\\s*",
"captures": {
"1": {
"name": "keyword.language.yaksha"
Expand Down

0 comments on commit 91b0394

Please sign in to comment.