Click here to Skip to main content
14,429,635 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: Wow, so this is cool, if you're a nerd like me Pin
glennPattonWork28-Nov-19 2:18
professionalglennPattonWork28-Nov-19 2:18 
GeneralSo I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 21:21
mvahoney the codewitch27-Nov-19 21:21 
GeneralRe: So I've decided to make my own programming language Pin
Super Lloyd27-Nov-19 21:31
MemberSuper Lloyd27-Nov-19 21:31 
GeneralRe: So I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 21:35
mvahoney the codewitch27-Nov-19 21:35 
GeneralRe: So I've decided to make my own programming language Pin
Jon McKee27-Nov-19 21:44
professionalJon McKee27-Nov-19 21:44 
GeneralRe: So I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 21:45
mvahoney the codewitch27-Nov-19 21:45 
GeneralRe: So I've decided to make my own programming language Pin
Jon McKee27-Nov-19 21:48
professionalJon McKee27-Nov-19 21:48 
GeneralRe: So I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 21:55
mvahoney the codewitch27-Nov-19 21:55 
It's kind of the house that jack built. Currently to render my shared codebase (such as table tokenizing support) in a language independent manner I have to render the entire thing using the codedom, as expression trees won't give me source code, and can't define whole classes.

Here's what I'm doing now:
var result = CD.Struct("Token", false,
	CD.Field(typeof(int), "Line", MemberAttributes.Public),
	CD.Field(typeof(int), "Column", MemberAttributes.Public),
	CD.Field(typeof(long), "Position", MemberAttributes.Public),
	CD.Field(typeof(int), "SymbolId", MemberAttributes.Public),
	CD.Field(typeof(string), "Value", MemberAttributes.Public));
result.CustomAttributes.Add(_GeneratedCodeAttribute);
return result;


in order to declare this:

public struct Token
{
	public int Line;
	public int Column;
	public long Position;
	public int SymbolId;
	public string Value;
}


And never mind methods like this:
result.Statements.AddRange(new CodeStatement[] {
	CD.If(CD.Invoke(input,"MoveNext"),
		CD.IfElse(CD.NotEq(state,CD.Literal(_BeforeBegin)), new CodeStatement[] {
			CD.Let(position,CD.Add(position,CD.One)),
			CD.IfElse(CD.Eq(CD.Literal('\n'),current),new CodeStatement[] {
				CD.Let(column,CD.One),
				CD.Let(line,CD.Add(line,CD.One))
			},
				CD.IfElse(CD.Eq(CD.Literal('\t'),current),new CodeStatement[]
				{
					CD.Let(column,CD.Add(column,CD.Literal(_TabWidth)))
				},
					CD.Let(column,CD.Add(column,CD.One))))
		},
		CD.IfElse(CD.Eq(CD.Literal('\n'),current),new CodeStatement[] {
			CD.Let(column,CD.One),
			CD.Let(line,CD.Add(line,CD.One))
		},
			CD.If(CD.Eq(CD.Literal('\t'),current),
				CD.Let(column,CD.Add(column,CD.Literal(_TabWidth-1))))
			)
		),
		CD.Return(CD.True)),
	CD.Let(state,CD.Literal(_InnerFinished)),
	CD.Return(CD.False)
});
return result;


to declare this:

bool _MoveNextInput()
{
	if (_input.MoveNext())
	{
		if (_BeforeBegin != _state)
		{
			++_position;
			if ('\n' == _input.Current)
			{
				_column = 1;
				++_line;
			}
			else if ('\t' == _input.Current)
				_column += _TabWidth;
			else
				++_column;
		} else
		{
			// corner case for first move
			if ('\n' == _input.Current)
			{
				_column = 1;
				++_line;
			}
			else if ('\t' == _input.Current)
				_column += _TabWidth-1;
		}
		return true;
	}
	_state = _InnerFinished;
	return false;
}


It's ridiculous, and I'd like to move away from it toward something more natural.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

GeneralRe: So I've decided to make my own programming language Pin
Jon McKee27-Nov-19 22:04
professionalJon McKee27-Nov-19 22:04 
GeneralRe: So I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 22:08
mvahoney the codewitch27-Nov-19 22:08 
GeneralRe: So I've decided to make my own programming language Pin
CPallini27-Nov-19 21:54
mveCPallini27-Nov-19 21:54 
GeneralRe: So I've decided to make my own programming language Pin
Sander Rossel27-Nov-19 22:26
professionalSander Rossel27-Nov-19 22:26 
GeneralRe: So I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 22:28
mvahoney the codewitch27-Nov-19 22:28 
PraiseRe: So I've decided to make my own programming language Pin
CPallini27-Nov-19 22:45
mveCPallini27-Nov-19 22:45 
GeneralRe: So I've decided to make my own programming language Pin
Super Lloyd27-Nov-19 23:43
MemberSuper Lloyd27-Nov-19 23:43 
GeneralRe: So I've decided to make my own programming language Pin
Amarnath S27-Nov-19 22:51
professionalAmarnath S27-Nov-19 22:51 
GeneralWell I failed at quitting smoking, and I blame the holidays. Pin
honey the codewitch27-Nov-19 20:47
mvahoney the codewitch27-Nov-19 20:47 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
Jörgen Andersson27-Nov-19 21:36
communityengineerJörgen Andersson27-Nov-19 21:36 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
OriginalGriff27-Nov-19 22:21
communityengineerOriginalGriff27-Nov-19 22:21 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
honey the codewitch27-Nov-19 22:22
mvahoney the codewitch27-Nov-19 22:22 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
Sander Rossel27-Nov-19 22:29
professionalSander Rossel27-Nov-19 22:29 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
honey the codewitch27-Nov-19 22:30
mvahoney the codewitch27-Nov-19 22:30 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
enhzflep30-Nov-19 2:16
Memberenhzflep30-Nov-19 2:16 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
honey the codewitch30-Nov-19 2:18
mvahoney the codewitch30-Nov-19 2:18 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
GKP199227-Nov-19 23:50
professionalGKP199227-Nov-19 23:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.