Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Bird Programming Language: Part 1

, 1 Jan 2013
A new general purpose language that aims to be fast, high level and simple to use.
Bird-noexe.zip
Bird
Archives
crt2.o
crtbegin.o
crtend.o
libadvapi32.a
libcomctl32.a
libcomdlg32.a
libgcc.a
libgdi32.a
libglu32.a
libkernel32.a
libmingw32.a
libmingwex.a
libmoldname.a
libmsvcrt.a
libopengl32.a
libshell32.a
libstdc++.a
libuser32.a
libwinmm.a
libwsock32.a
Libraries
BirdCore
Array.bird
BigInteger.bird
BinaryRW.bird
BirdCore.a
BirdCore.blib
CategoryData.dat
Console.bird
Convert.bird
Debug.bird
Entry.bird
Environment.bird
Exception.bird
Float.bird
LEB128.bird
Math.bird
Memory.bird
Object.bird
Random.bird
Reflection.bird
StandardC.bird
Stream.bird
String.bird
ToLowerData.dat
ToUpperData.dat
Types.bird
ValueType.bird
Win32.bird
x86Helper.bird
BlitzMax
.bmx
Launcher.bmx.gui.release.win32.x86.o
appstub.release.win32.x86.a
bank.release.win32.x86.a
bankstream.release.win32.x86.a
blitz.release.win32.x86.a
BlitzMax.a
BlitzMax.bird
BlitzMax.blib
d3d7max2d.release.win32.x86.a
d3d9max2d.release.win32.x86.a
directx.release.win32.x86.a
dxgraphics.release.win32.x86.a
event.release.win32.x86.a
filesystem.release.win32.x86.a
font.release.win32.x86.a
glgraphics.release.win32.x86.a
glmax2d.release.win32.x86.a
graphics.release.win32.x86.a
hook.release.win32.x86.a
keycodes.release.win32.x86.a
Launcher.bmx
libpng.release.win32.x86.a
linkedlist.release.win32.x86.a
math.release.win32.x86.a
max2d.release.win32.x86.a
opengl.release.win32.x86.a
pixmap.release.win32.x86.a
pngloader.release.win32.x86.a
polledinput.release.win32.x86.a
standardio.release.win32.x86.a
stdc.release.win32.x86.a
stream.release.win32.x86.a
system.release.win32.x86.a
textstream.release.win32.x86.a
win32.release.win32.x86.a
zlib.release.win32.x86.a
PrgLinec.bmx
Samples
Circles
Circles.bird
CppMain.bird
Fire
Fire.bird
Higher Order Functions
C#
Higher Order Functions.v11.suo
Properties
Test.bird
msvcrt.lib
Reflection
Reflection.bird
Squares
Squares.bird
Template
Template.bird
Source
Base
Bird.v11.suo
Expressions
Identifiers
Languages
NativeCode
Properties
Recognizers
Expressions
Scopes
x86
Thumbs.db
Bird.zip
crt2.o
crtbegin.o
crtend.o
libadvapi32.a
libcomctl32.a
libcomdlg32.a
libgcc.a
libgdi32.a
libglu32.a
libkernel32.a
libmingw32.a
libmingwex.a
libmoldname.a
libmsvcrt.a
libopengl32.a
libshell32.a
libstdc++.a
libuser32.a
libwinmm.a
libwsock32.a
Binaries
ar.exe
Bird.exe
fasm.exe
ld.exe
libiconv-2.dll
libintl-8.dll
Array.bird
BigInteger.bird
BinaryRW.bird
BirdCore.a
BirdCore.blib
CategoryData.dat
Console.bird
Convert.bird
Debug.bird
Entry.bird
Environment.bird
Exception.bird
Float.bird
LEB128.bird
Math.bird
Memory.bird
Object.bird
Random.bird
Reflection.bird
StandardC.bird
Stream.bird
String.bird
ToLowerData.dat
ToUpperData.dat
Types.bird
ValueType.bird
Win32.bird
x86Helper.bird
Launcher.bmx.gui.release.win32.x86.o
appstub.release.win32.x86.a
bank.release.win32.x86.a
bankstream.release.win32.x86.a
blitz.release.win32.x86.a
BlitzMax.a
BlitzMax.bird
BlitzMax.blib
d3d7max2d.release.win32.x86.a
d3d9max2d.release.win32.x86.a
directx.release.win32.x86.a
dxgraphics.release.win32.x86.a
event.release.win32.x86.a
filesystem.release.win32.x86.a
font.release.win32.x86.a
glgraphics.release.win32.x86.a
glmax2d.release.win32.x86.a
graphics.release.win32.x86.a
hook.release.win32.x86.a
keycodes.release.win32.x86.a
Launcher.bmx
libpng.release.win32.x86.a
linkedlist.release.win32.x86.a
math.release.win32.x86.a
max2d.release.win32.x86.a
opengl.release.win32.x86.a
pixmap.release.win32.x86.a
pngloader.release.win32.x86.a
polledinput.release.win32.x86.a
standardio.release.win32.x86.a
stdc.release.win32.x86.a
stream.release.win32.x86.a
system.release.win32.x86.a
textstream.release.win32.x86.a
win32.release.win32.x86.a
zlib.release.win32.x86.a
PrgLinec.bmx
PrgLinec.exe
Circles.bird
CppMain.bird
Fire.bird
Higher Order Functions.v11.suo
Test.bird
msvcrt.lib
Reflection.bird
Squares.bird
Template.bird
Bird.v11.suo
Thumbs.db
examples.zip
Examples
As.exe
AsLibs.a
PerfTest
Launcher.bmx
Squares
.bmx
Launcher.bmx
Template
Launcher.bmx
source.zip
Anonymus 7_1
Anonymus.csproj.user
Anonymus.idc
Anonymus.pidb
Anonymus.suo
Anonymus.userprefs
Base
Expressions
Lib
Long
LongDivTest.bmx
ULongConv.bmx
Math
MISZ
AsLibs.a
PerfTest
Launcher.bmx
Squares
Launcher.bmx
Template
Launcher.bmx
PrgLinec.bmx
PrgLinec.exe
Properties
Scopes
Txt
Asm.docx
Code.docx
Lib.aslib
~$Code.docx
x86
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Anonymus.Recognizers;

namespace Anonymus.AsLang
{
	public delegate bool AsForEachLineFunc(ScopeNode Scope, PString Line, int LineIndex);
	public static class AnonymusHelper
	{
		public static bool ChkIndent(ScopeNode Scope, PString Line, ref int Indent, bool Err)
		{
			var State = Scope.State;
			var CIndent = State.GetIndent(Line.String);

			if (Indent == -1) Indent = CIndent;
			else if (Indent != CIndent && Err)
			{
				State.Messages.Add(MessageId.InvalidScopeIndent, Line);
				return false;
			}

			return true;
		}

		public static bool ForEachLine(ScopeNode Scope, AsForEachLineFunc Func, bool ChkIndent = true)
		{
			var Source = Scope.Source;
			var RetValue = true;

			if (Source != null)
			{
				var Indent = -1;
				for (var LineIndex = 0; LineIndex < Source.Length; LineIndex++)
				{
					var _TLine = Source[LineIndex];
					if (_TLine == null) continue;

					var Line = _TLine.Trim();
					if (Line.String != "")
					{
						if (!AnonymusHelper.ChkIndent(Scope, _TLine, ref Indent, ChkIndent))
							RetValue = false;

						if (!Func(Scope, Line, LineIndex))
							RetValue = false;
					}
				}
			}

			return RetValue;
		}
	}

	public class AsDeclarationRecognizer : DeclarationRecognizer
	{
		public bool _ProcessScopeFunc(ScopeNode Scope, PString Line, int LineIndex)
		{
			var PScope = Scope as ProcessableScope;
			var State = Scope.State;
			var FLine = Line.Copy();
			var Word = Line.Word();

			//-----------------------------------------------------------------------
			if (Word.String == "import")
			{
				Line.TrimThis();
				if (!(Scope is GlobalScopeNode))
				{
					State.Messages.Add(MessageId.MustBeGlobal, Line, Word.String);
					return false;
				}

				var ConstNode = Expressions.GetStringNode(Line, Scope);
				if (ConstNode == null) return false;

				Scope.Source[LineIndex] = null;
				var Library = ConstNode.String;

				if (!File.Exists(Library))
				{
					State.Messages.Add(MessageId.FileDoesntExists, Line);
					return false;
				}
				else if (!LibraryLoader.LoadLibrary(Library, Scope))
				{
					State.Messages.Add(MessageId.InvalidFile, Line);
					return false;
				}

				return true;
			}

			//-----------------------------------------------------------------------
			else if (Word.String == "dllimport")
			{
				if (!(Scope is GlobalScopeNode))
				{
					State.Messages.Add(MessageId.MustBeGlobal, Line, Word.String);
					return false;
				}

				var Inner = Scope.InnerScope(null, LineIndex);
				if (Inner == null) return false;

				var ConstNode = Expressions.GetStringNode(Line, Scope);
				if (ConstNode == null) return false;
				var Library = ConstNode.String;

				var NewScope = new ImportScopeNode(Scope, Library, Inner);
				if (!NewScope.ProcessScope())
					return false;

				var GlbScope = Scope as GlobalScopeNode;
				if (GlbScope.ImportScopes == null)
					GlbScope.ImportScopes = new List<ImportScopeNode>();
				GlbScope.ImportScopes.Add(NewScope);
				return true;
			}

			//-----------------------------------------------------------------------
			else if (Word.String == "extern")
			{
				if (!(Scope is GlobalScopeNode))
				{
					State.Messages.Add(MessageId.MustBeGlobal, Line, Word.String);
					return false;
				}

				if (State.Format != ImageFormat.MSCoff)
				{
					State.Messages.Add(MessageId.ExternNonMSCoff, Word);
					return false;
				}

				var Inner = Scope.InnerScope(null, LineIndex);
				if (Inner == null) return false;

				var GlbScope = Scope as GlobalScopeNode;
				var NewScope = new ExternScopeNode(Scope, Inner);
				if (!NewScope.ProcessScope())
					return false;

				if (GlbScope.ExternScopes == null)
					GlbScope.ExternScopes = new List<ExternScopeNode>();
				GlbScope.ExternScopes.Add(NewScope);
				return true;
			}

			//-----------------------------------------------------------------------
			var Mods = Modifiers.GetModifiers(State, ref FLine);
			if (Mods == null) return false;
			return ProcDeclaration(PScope, FLine, LineIndex, Mods);
		}

		public bool ProcDeclaration(ProcessableScope Scope, PString Line, int LineIndex, ModifierList Mods = null)
		{
			var State = Scope.State;
			if (Line.Length == 0) return true;
			Line = Line.Trim();

			var Z_Start = -1;
			if ((Z_Start = Line.IndexOf('(', InZ: true, Start: 1)) != -1)
			{
				var FLine = Line.Copy();
				var TypeName = Line.TrimmedSubstring(0, Z_Start);
				Line = Line.Substring(Z_Start);

				var Z_End = BracketHelper.ZPos(Line.String);
				if (Z_End == -1)
				{
					State.Messages.Add(MessageId.ZNumErr, Line.Substring(0, 1));
					return false;
				}

				var Params = Line.Substring(1, Z_End - 1);
				Line = Line.Substring(Z_End + 1);

				var Name = TypeName.Word(Back: true);
				var Inner = Scope.FInnerScope(FLine, Line, LineIndex, Warning: !(Scope is ExternScopeNode));
				if (Inner == null) return false;
				var DeclList = new VarDeclList();
				if (!DeclList.AddFromString(Scope, Params)) return false;

				if (TypeName.StrLen == 0)
				{
					if (!Scope.OnUnTypedFuncDecl(Mods, Name, DeclList, Inner))
						return false;
				}
				else
				{
					if (!Scope.OnTypedFuncDecl(Mods, TypeName, Name, DeclList, Inner))
						return false;
				}
			}
			else
			{
				if (!Scope.DeclareVariables(Line, Mods, IdMode: GetIdMode.Function))
					return false;
			}

			return true;
		}

		public override bool Recognize(ProcessableScope Scope)
		{
			return AnonymusHelper.ForEachLine(Scope, _ProcessScopeFunc);
		}
	}

	public class AsInnerScopeRecognizer : InnerScopeRecognizer
	{
		public static int NLine(ScopeNode Scope, int From)
		{
			var Source = Scope.Source;
			var State = Scope.State;

			for (var i = From; i < Source.Length; i++)
			{
				var Line = Source[i];
				if (Line == null) continue;

				var Indent = State.GetIndent(Line.String);
				if (Line.Trim().StrLen != 0) return i;
			}

			return -1;
		}

		public static int NLineIndent(ScopeNode Scope, int From)
		{
			var Source = Scope.Source;
			var State = Scope.State;

			var Index = NLine(Scope, From);
			if (Index == -1) return -1;

			var Line = Source[Index];
			return State.GetIndent(Line.String);
		}

		public static int ScopeEnd(ScopeNode Scope, int Index, int Indent)
		{
			var Source = Scope.Source;
			var State = Scope.State;

			var Pos = -1;
			for (var i = Index; i < Source.Length; i++)
			{
				var Ln = Source[i];
				if (Ln != null && Ln.String.Trim() != "")
				{
					if (State.GetIndent(Ln.String) <= Indent)
					{
						Pos = i;
						break;
					}
				}
			}

			if (Pos == -1) Pos = Source.Length;
			return Pos - 1;
		}

		public override PString[] GetInnerScope(ScopeNode Scope, PString Line, int Index, bool Mod = true, object Data = null)
		{
			var Source = Scope.Source;
			var State = Scope.State;

			var Indent = State.GetIndent(Source[Index]);
			Source[Index] = null;
			var NLine = Index + 1;
			var EmptyLine = Line == null || Line.String.Trim() == "";

			if (NLineIndent(Scope, NLine) <= Indent)
			{
				if (!EmptyLine) return new PString[] { Line };
				else return new PString[0];
			}

			var End = ScopeEnd(Scope, NLine, Indent);
			var Ret = (PString[])null;

			if (!EmptyLine)
			{
				Ret = Source.Slice(Index, End - Index + 1);
				Ret[0] = Line;
			}
			else
			{
				Ret = Source.Slice(NLine, End - NLine + 1);
			}

			if (Mod)
			{
				for (var i = NLine; i <= End; i++)
					Source[i] = null;
			}

			if (Ret == null) throw new Exception("ERROR");
			return Ret;
		}
	}


	public class AsTypeDeclRecognizer : TypeDeclRecognizer
	{
		public override List<TypeDecl> Recognize(ScopeNode Scope)
		{
			var Ret = new List<TypeDecl>();
			var State = Scope.State;
			var Lines = Scope.Source;
			var CIndent = -1;
			var RetValue = true;

			if (Lines == null) return Ret;
			for (var i = 0; i < Lines.Length; i++)
			{
				if (Lines[i] == null) continue;
				var Indent = State.GetIndent(Lines[i]);
				var Line = Lines[i].Trim();
				if (Line.StrLen == 0) continue;

				if (CIndent == -1) CIndent = Indent;
				else if (CIndent != Indent) continue;

				var Mods = Modifiers.GetModifiers(State, ref Line);
				if (Mods == null)
				{
					RetValue = false;
					continue;
				}

				var FLine = Line.Copy();
				var Word = Line.Word();
				TypeDeclType Type;

				if (Word.String == "class") Type = TypeDeclType.Class;
				else if (Word.String == "struct") Type = TypeDeclType.Struct;
				else if (Word.String == "enum") Type = TypeDeclType.Enum;
				else if (Word.String == "flag") Type = TypeDeclType.Flag;
				else if (Word.String == "type") Type = TypeDeclType.TypeDef;
				else continue;

				Lines[i] = null;
				if (Type != TypeDeclType.TypeDef)
				{
					var Name = Line.Word();
					if (Name == null || Name.StrLen == 0)
					{
						State.Messages.Add(MessageId.Unnamed, FLine);
						RetValue = false;
						continue;
					}
					else
					{
						var Base = (PString)null;
						var BasePos = Line.IndexOf(':', InZ: true);
						if (BasePos != -1)
						{
							Base = Line.TrimmedSubstring(BasePos + 1);
							Line = Line.TrimmedSubstring(0, BasePos);
							if (!State.ChkNotExpected(Line)) return null;
						}

						var Inner = Scope.InnerScope(null, i);
						if (Inner == null) RetValue = false;
						else Ret.Add(new TypeDecl(Scope, Name, Type, Base, Inner, Mods));
					}
				}
				else
				{
					var SplString = new List<PString>();
					var Recognizer = State.Language.ArgRecognizer;
					if (!Recognizer.SplitArgs(State, Line, SplString))
						RetValue = false;

					foreach (var e in SplString)
					{
						var p = e.IndexOf('=', InZ: true);
						if (p == -1)
						{
							State.Messages.Add(MessageId.DeficientExpr, e);
							RetValue = false;
							continue;
						}

						var Val = Line.TrimmedSubstring(p + 1);
						Line = Line.TrimmedSubstring(0, p);
						var Name = Line.Word(Back: true);
						Val.TrimThis();

						if (Line.StrLen > 0)
						{
							State.Messages.Add(MessageId.TypeCannotBeSpecified, Line);
							RetValue = false;
							continue;
						}

						Ret.Add(new TypeDecl(Scope, Name, Type, Val, null, Mods));
					}
				}
			}

			if (!RetValue) return null;
			return Ret;
		}
	}

	public class AsVarRecognizer : VarDeclRecognizer
	{
		public override List<VarDecl> Recognize(IdContainer Container, PString Code, bool EnableMessages)
		{
			var State = Container.State;
			Code = Code.Trim();
			if (Code.String == "") return new List<VarDecl>();

			var SplString = new List<PString>();
			var Recognizer = State.Language.ArgRecognizer;
			if (!Recognizer.SplitArgs(State, Code, SplString, EnableMessages))
				return null;

			var RetValue = true;
			var Unnamed = false;
			var Type = (Type)null;
			var TypeName = (PString)null;
			var Ret = new List<VarDecl>();

			for (var i = 0; i < SplString.Count; i++)
			{
				var e = SplString[i];
				var p = e.IndexOf('=', InZ: true);
				if (p == -1) p = e.StrLen;

				var Def = e.TrimmedSubstring(0, p);
				var Name = Def.Word(Back: true, InZ: true);
				Def.TrimThis();

				//---------------------------------------------------------------------------------
				var TypeSpecified = false;
				if (Def.StrLen > 0)
				{
					if (Unnamed)
					{
						if (EnableMessages) State.Messages.Add(MessageId.MustBeUnnamed, e);
						return null;
					}

					TypeName = Def;
					TypeSpecified = true;
				}
				else
				{
					if (i == 0) Unnamed = true;

					if (Unnamed)
					{
						TypeName = Name;
						Name = null;
						TypeSpecified = true;
					}
				}

				//---------------------------------------------------------------------------------
				if (TypeSpecified)
				{
					if ((Type = Container.GetId<Type>(TypeName)) == null) RetValue = false;
					else Type.SetUsed();
				}
				else if (TypeName == null)
				{
					if (EnableMessages) State.Messages.Add(MessageId.TypeNotSpecified, Name);
					RetValue = false;
				}

				//---------------------------------------------------------------------------------
				var InitString = (PString)null;
				if (p != e.Length)
				{
					InitString = e.TrimmedSubstring(p + 1);
					if (InitString.StrLen == 0)
					{
						if (EnableMessages) State.Messages.Add(MessageId.DeficientExpr, e);
						RetValue = false;
					}
				}

				var TN = TypeSpecified ? TypeName : null;
				Ret.Add(new VarDecl(e, TN, Type, Name, InitString));
			}

			if (!RetValue) return null;
			return Ret;
		}
	}

	public class AsExprRecognizers : MultiExprRecognizer
	{
		public AsExprRecognizers()
		{
			Recognizers.Add(new SimpleArgRecognizer());
			Recognizers.Add(new LiteralRecognizer());
			Recognizers.Add(new IdRecognizer());
			Recognizers.Add(new RefRecognizer());
			Recognizers.Add(new NewRecognizer());
			Recognizers.Add(new IfThenRecognizer());
			Recognizers.Add(new AssignmentRecognizer());
			Recognizers.Add(new TupleCreatingRecognizer());
			Recognizers.Add(new LogicalRecognizer());
			Recognizers.Add(new RelEquRecognizer());
			Recognizers.Add(new AdditiveRecognizer());
			Recognizers.Add(new MultiplicativeRecognizer());
			Recognizers.Add(new ShiftRecognizer());
			Recognizers.Add(new BitwiseRecognizer());
			Recognizers.Add(new CastRecognizer());
			Recognizers.Add(new NegateRecognizer());
			Recognizers.Add(new NotRecognizer());
			Recognizers.Add(new AddressRecognizer());
			Recognizers.Add(new IncDecRecognizer());
			Recognizers.Add(new IndirectionRecognizer());

			var FuncKeywords = new List<KeywordFuncRecognizer>()
			{
				new IsDefinedRecognizer(),
				new SizeOfRecognizer(),
				new MathFuncsRecognizer(),
			};
			Recognizers.Add(new CallIndexRecognizer(FuncKeywords));
			Recognizers.Add(new NullCoalescingRecognizer());
			Recognizers.Add(new SafeNavigationRecognizer());
			Recognizers.Add(new MemberRecognizer());
			Recognizers.Add(new ExprVarDeclRecognizer());
			Init();
		}
	}

	public class AsCommRecognizers : MultiCommRecognizer
	{
		public AsCommRecognizers()
		{
			Recognizers.Add(new AsmCommRecognizer());
			Recognizers.Add(new IfCommRecognizer());
			Recognizers.Add(new ElseCommRecognizer());
			Recognizers.Add(new LabelCommRecognizer());
			Recognizers.Add(new GotoCommRecognizer());
			Recognizers.Add(new BreakCommRecognizer());
			Recognizers.Add(new ContinueCommRecognizer());
			Recognizers.Add(new SwitchCommRecognizer());
			Recognizers.Add(new CaseCommRecognizer());
			Recognizers.Add(new DefaultCommRecognizer());
			Recognizers.Add(new WhileCommRecognizer());
			Recognizers.Add(new DoCommRecognizer());
			Recognizers.Add(new RepeatCommRecognizer());
			Recognizers.Add(new ForCommRecognizer());
			Recognizers.Add(new MoreCommRecognizer());
			Recognizers.Add(new ReturnCommRecognizer());
			Recognizers.Add(new VarDeclCommRecognizer());
			Recognizers.Add(new ExprCommRecognizer());
			Recognizers.Add(new FuncCallCommRecognizer());
		}
	}

	public class AsCodeProcessor : CodeProcessor
	{
		public bool _ProcessScopeFunc(ScopeNode Scope, PString Line, int LineIndex)
		{
			var CScope = Scope as CodeScopeNode;
			return CScope.RecognizeCommand(Line, LineIndex);
		}

		public override bool Process(CodeScopeNode Scope)
		{
			return AnonymusHelper.ForEachLine(Scope, _ProcessScopeFunc);
		}
	}

	public class AsGlobalScopeProcessor : GlobalScopeProcessor
	{
		public static string[] KStr = new string[] { "rem" };
		public static string[] KStr2 = new string[] { "'" };

		public bool _PreProcFunc(ScopeNode Scope, PString Line, int LineIndex)
		{
			var GScope = Scope as GlobalScopeNode;
			var Source = Scope.Source;

			var Preprocessor = new Preprocessor(GScope);
			var PRes = Preprocessor.PreprocessLine(Line);

			if (PRes == PreprocessorRes.Failed) return false;
			else if (PRes != PreprocessorRes.NotPreprocLine)
			{
				Source[LineIndex] = null;
			}
			else
			{
				var Ord = Line.Word();
				if (Ord.String == "rem")
				{
					if (Scope.InnerScope(Line, LineIndex) == null)
						return false;
				}
				else
				{
					Line = Source[LineIndex];
					var FindRes = Line.String.Find(KStr, NotIdChar: true);
					if (FindRes.Position == -1) FindRes = Line.String.Find(KStr2);

					if (FindRes.Index != -1)
						Source[LineIndex] = Line.Substring(0, FindRes.Position);
				}
			}

			return true;
		}

		public void ConvLines(GlobalScopeNode Scope)
		{
			var Source = Scope.Source;
			var State = Scope.State;

			for (var i = Source.Length - 2; i >= 0; i--)
				if (Source[i] != null)
				{
					var Line = Source[i];
					var TrmStr = Line.String.Trim();
					if (TrmStr.Length == 0)
					{
						Source[i] = null;
						continue;
					}

					var NextLineIndex = -1;
					for (var j = i + 1; j < Source.Length; j++)
						if (Source[j] != null)
						{
							NextLineIndex = j;
							break;
						}

					var NextLine = NextLineIndex != -1 ? Source[NextLineIndex] : null;
					var NextIndent = NextLine != null ? State.GetIndent(NextLine.String) : -1;
					var Indent = State.GetIndent(Line.String);

					if (Indent <= NextIndent)
					{
						var Rec = State.Language.ExprRecognizer;
						var Ok = TrmStr.EndsWith(Rec.NewLineRight, Rec.OnlyLeft, true).Position != -1;
						var LChar = TrmStr[TrmStr.Length - 1];

						if (!Ok && LChar == '.' && TrmStr.EndsWith(".."))
						{
							Source[i].String = TrmStr.Substring(0, TrmStr.Length - 2);
							Ok = true;
						}

						if (Ok)
						{
							Source[i].String += "\n" + Source[NextLineIndex].String;
							Source[NextLineIndex] = null;
						}
					}
				}
		}

		public override bool Process(GlobalScopeNode Scope)
		{
			ConvLines(Scope);
			if (!AnonymusHelper.ForEachLine(Scope, _PreProcFunc, false))
				return false;

			return true;
		}
	}

	public class AsLanguage : Language
	{
		public AsLanguage()
		{
			ExprRecognizer = new AsLang.AsExprRecognizers();
			CommRecognizer = new AsLang.AsCommRecognizers();
			InnerScopeRecognizer = new AsLang.AsInnerScopeRecognizer();
			VarDeclRecognizer = new AsLang.AsVarRecognizer();
			TypeDeclRecognizer = new AsLang.AsTypeDeclRecognizer();
			DeclarationRecognizer = new AsLang.AsDeclarationRecognizer();
			CodeProcessor = new AsLang.AsCodeProcessor();
			GlobalScopeProcessor = new AsLang.AsGlobalScopeProcessor();
			Init();
		}
	}

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

Dávid Kocsis
Student
Hungary Hungary
I've been programming for 8 years. My first big project was a remake of a nice bomberman game called Dyna Blaster. When i was little i played a lot with it. Now i'm working on a new programming language and code generator.
I would like to work with someone, so feel free to contact me about it.

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 1 Jan 2013
Article Copyright 2011 by Dávid Kocsis
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid