Click here to Skip to main content
15,903,203 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
glennPattonWork328-Nov-19 1:18
professionalglennPattonWork328-Nov-19 1:18 
GeneralSo I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 20:21
mvahoney the codewitch27-Nov-19 20:21 
GeneralRe: So I've decided to make my own programming language Pin
Super Lloyd27-Nov-19 20:31
Super Lloyd27-Nov-19 20:31 
GeneralRe: So I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 20:35
mvahoney the codewitch27-Nov-19 20:35 
GeneralRe: So I've decided to make my own programming language Pin
Jon McKee27-Nov-19 20:44
professionalJon McKee27-Nov-19 20:44 
GeneralRe: So I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 20:45
mvahoney the codewitch27-Nov-19 20:45 
GeneralRe: So I've decided to make my own programming language Pin
Jon McKee27-Nov-19 20:48
professionalJon McKee27-Nov-19 20:48 
GeneralRe: So I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 20:55
mvahoney the codewitch27-Nov-19 20: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:
C#
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:

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


And never mind methods like this:
C#
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:

C#
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 21:04
professionalJon McKee27-Nov-19 21:04 
GeneralRe: So I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 21:08
mvahoney the codewitch27-Nov-19 21:08 
GeneralRe: So I've decided to make my own programming language Pin
CPallini27-Nov-19 20:54
mveCPallini27-Nov-19 20:54 
GeneralRe: So I've decided to make my own programming language Pin
Sander Rossel27-Nov-19 21:26
professionalSander Rossel27-Nov-19 21:26 
GeneralRe: So I've decided to make my own programming language Pin
honey the codewitch27-Nov-19 21:28
mvahoney the codewitch27-Nov-19 21:28 
PraiseRe: So I've decided to make my own programming language Pin
CPallini27-Nov-19 21:45
mveCPallini27-Nov-19 21:45 
GeneralRe: So I've decided to make my own programming language Pin
Super Lloyd27-Nov-19 22:43
Super Lloyd27-Nov-19 22:43 
GeneralRe: So I've decided to make my own programming language Pin
Amarnath S27-Nov-19 21:51
professionalAmarnath S27-Nov-19 21:51 
GeneralWell I failed at quitting smoking, and I blame the holidays. Pin
honey the codewitch27-Nov-19 19:47
mvahoney the codewitch27-Nov-19 19:47 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
Jörgen Andersson27-Nov-19 20:36
professionalJörgen Andersson27-Nov-19 20:36 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
OriginalGriff27-Nov-19 21:21
mveOriginalGriff27-Nov-19 21:21 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
honey the codewitch27-Nov-19 21:22
mvahoney the codewitch27-Nov-19 21:22 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
Sander Rossel27-Nov-19 21:29
professionalSander Rossel27-Nov-19 21:29 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
honey the codewitch27-Nov-19 21:30
mvahoney the codewitch27-Nov-19 21:30 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
enhzflep30-Nov-19 1:16
enhzflep30-Nov-19 1:16 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
honey the codewitch30-Nov-19 1:18
mvahoney the codewitch30-Nov-19 1:18 
GeneralRe: Well I failed at quitting smoking, and I blame the holidays. Pin
GKP199227-Nov-19 22:50
professionalGKP199227-Nov-19 22: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.