mirror of
https://github.com/Cekis/SWG-ScriptConverter.git
synced 2026-09-12 23:45:00 -04:00
Add code
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using ScriptConverter.Ast.Declarations;
|
||||
|
||||
namespace ScriptConverter.Parser.Parselets.Declarations
|
||||
{
|
||||
class IncludeParselet : IDeclarationParselet
|
||||
{
|
||||
public Declaration Parse(ScriptParser parser, ScriptToken token)
|
||||
{
|
||||
var done = false;
|
||||
var tokens = parser.ParseSeparatedBy(ScriptTokenType.Dot, (_, first) =>
|
||||
{
|
||||
if (done)
|
||||
return null;
|
||||
|
||||
if (parser.Match(ScriptTokenType.Multiply))
|
||||
{
|
||||
done = true;
|
||||
return parser.Take(ScriptTokenType.Multiply);
|
||||
}
|
||||
|
||||
return parser.Take(ScriptTokenType.Identifier);
|
||||
});
|
||||
|
||||
var name = string.Join(".", tokens.Select(t => t.Contents));
|
||||
|
||||
if (!parser.MatchAndTake(ScriptTokenType.Semicolon))
|
||||
Console.WriteLine("JFjngkjasnholjhnaskl");
|
||||
|
||||
return new IncludeDeclaration(token, parser.Previous, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user