Skip to content

Commit

Permalink
Merge pull request #91 from AIexandrKotov/patch0.5.2
Browse files Browse the repository at this point in the history
Patch0.5.2
  • Loading branch information
AIexandrKotov authored Dec 9, 2023
2 parents 05106dd + 179b470 commit 2a16e50
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ end.
| 1.0.0 | 0.2.0+ |

### Download
[![stable](https://img.shields.io/badge/REPL_stable-1.1.0-00cc00)](https://github.com/AIexandrKotov/SLThree/releases/tag/0.4.0) [![stable](https://img.shields.io/badge/LANG_exp-0.5.1-ccaa00)](https://github.com/AIexandrKotov/SLThree/releases/tag/0.5.1)
[![stable](https://img.shields.io/badge/REPL_stable-1.1.0-00cc00)](https://github.com/AIexandrKotov/SLThree/releases/tag/0.4.0) [![stable](https://img.shields.io/badge/LANG_exp-0.5.2-ccaa00)](https://github.com/AIexandrKotov/SLThree/releases/tag/0.5.2)
9 changes: 8 additions & 1 deletion SLThree/Extensions/SLTHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,14 @@ public static object CastToType(this object o, Type casting_type)
var type = o.GetType();
if (type == type_context)
{
return NonGenericWrapper.GetWrapper(casting_type).Unwrap(((ExecutionContext.ContextWrap)o).pred);
var wrapper = NonGenericWrapper.GetWrapper(casting_type);
if (casting_type.IsAbstract)
{
if (casting_type.IsSealed) wrapper.UnwrapStaticClass(((ExecutionContext.ContextWrap)o).pred);
else wrapper.UnwrapStatic(((ExecutionContext.ContextWrap)o).pred);
return null;
}
else return wrapper.Unwrap(((ExecutionContext.ContextWrap)o).pred);
}
if (casting_type.IsEnum)
{
Expand Down
1 change: 1 addition & 0 deletions SLThree/Lexems/CastLexem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public override object GetValue(ExecutionContext context)
{
var obj = Right.GetValue(context);
if (obj == null) throw new RuntimeError($"Type \"{name}\" not found", Right.SourceContext);
if (obj is Type tp) return Left.GetValue(context).CastToType(tp);
return Left.GetValue(context).CastToType((obj as MemberAccess.ClassAccess).Name);
}

Expand Down
6 changes: 3 additions & 3 deletions SLThree/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
public static class SLTVersion {
public const string Major = "0"; //vh
public const string Minor = "5"; //vh
public const string Build = "1"; //vh
public const string Revision = "1636"; //vh
public const long LastUpdate = 638359852703787290; //vh
public const string Build = "2"; //vh
public const string Revision = "1645"; //vh
public const long LastUpdate = 638377197159648039; //vh

public const string Version = Major + "." + Minor + "." + Build + "." + Revision;
public const string VersionWithoutRevision = Major + "." + Minor + "." + Build;
Expand Down
1 change: 1 addition & 0 deletions SLThree/SLThree.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<EmbeddedResource Include="docs\versions\0.4.0" />
<EmbeddedResource Include="docs\versions\0.5.0" />
<EmbeddedResource Include="docs\versions\0.5.1" />
<EmbeddedResource Include="docs\versions\0.5.2" />
<None Include="packages.config" />
<PegGrammar Include="syntax.peg" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions SLThree/docs/versions/0.5.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
------ 0.5.2 Patch ------ [09.12.23]
Bugfixes:
- Correct behaviour of comments
- x as typeof(T), x as @T
40 changes: 21 additions & 19 deletions SLThree/syntax.peg
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ statement_ws <BaseStatement>
/ _ st:while_statement _ { st }
/ _ st:condition_statement _ { st }
/ _ st:block_statement _ { st }
/ _ st:statement _ ";" { st }
/ _ ";"+ _ { new StatementListStatement(new BaseStatement[0], state) }
/ _ st:statement _ ";" _ { st }
/ _ (";" _)+ { new StatementListStatement(new BaseStatement[0], state) }
/ _ st:statement _ { Panic<StatementListStatement>(new SyntaxError("Expected ;", state)) }

statement <BaseStatement>
= _ st:return_statement _ { st }
/ _ st:break_statement _ { st }
/ _ st:continue_statement _ { st }
/ _ st:using_statement _ { st }
/ _ st:context_statement _ { st }
/ _ st:condition_statement _ { st }
/ _ st:switch_statement _ { st }
/ _ st:foreach_statement _ { st }
/ _ st:while_statement _ { st }
/ _ st:block_statement _ { st }
/ _ st:expr_statement _ { st }
= st:return_statement { st }
/ st:break_statement { st }
/ st:continue_statement { st }
/ st:using_statement { st }
/ st:context_statement { st }
/ st:condition_statement { st }
/ st:switch_statement { st }
/ st:foreach_statement { st }
/ st:while_statement { st }
/ st:block_statement { st }
/ st:expr_statement { st }

using_statement <UsingStatement>
= "using" _required_ ex: as_expr_right _ gens:generic_types _ "as" _required_ n:name {
Expand Down Expand Up @@ -237,6 +237,8 @@ binary_1 <BaseLexem> -memoize

binary_0 <BaseLexem> -memoize
= left:binary_0 _ "as" _ "\\" { new CastLexem(left, new NameLexem("\\", state), state) }
/ left:binary_0 _ "as" _required_ "@" _ refl:as_expr_right { new CastLexem(left, new ReflectionLexem(refl, refl.SourceContext), state) }
/ left:binary_0 _ "as" _required_ "typeof" _ "(" _ tp:primary _ ")" { new CastLexem(left, new TypeofLexem(tp, tp.SourceContext), state) }
/ left:binary_0 _ "as" _required_ right:as_expr_right { new CastLexem(left, right, state) }
/ _ left:binary_min _ { left }

Expand Down Expand Up @@ -461,14 +463,14 @@ available_name <IList<string>>
comment
= "//" [^\r\n]*

_required_
= [ \t\r\n]+ comment+ [ \t\r\n]* { " " }
/ comment+ [ \t\r\n]* { " " }
_required_
= [ \t]+ comment _ { " " }
/ comment _ { " " }
/ [ \t\r\n]+ { " " }

_
= [ \t\r\n]* comment+ [ \t\r\n]* { " " }
/ comment+ [ \t\r\n]* { " " }
= [ \t]* comment _ { " " }
/ comment _ { " " }
/ [ \t\r\n]* { " " }

EOF = !. / c:. { Panic<string>(new UnexpectedError(c[0], state)) }
EOF = !. / comment / c:. { Panic<string>(new UnexpectedError(c[0], state)) }

0 comments on commit 2a16e50

Please sign in to comment.