0

i'm developing a "videogame" to teach programming for my college.

This videogame is level based, in where each level is about a programming subject(Variables, data structures, etc.) and given that subject then the level will be a puzzle or a 2d platformer so for example in the level of conditionals it will be a 2d platformer where the user has to introduce via a gui console the instructions to make the character check if there's something blocking the way or something like that.

what i need is some code that given the input in that console it will check for syntactic and semantic errors. The input will be based on a language of choice (i'm thinking C#) but there's nothing 100% sure about that. (I mean that i'm thinking of teaching C#, but i could teach any other language)

right now i'm in the task of building the console but it is very difficult for me as i'm not an advanced programmer.

I've been searching in the internet for some parsers or stuff that just check those two things and for example return booleans, but i've only found compiler-compiler stuff like GOLD or ANTLR and i think that it is not necesary for the scale of the project.

How could i develop such parser or can you point me to one?

EDIT : maybe a good example of what i want to accomplish is something like codecademy's console or the tryhaskell.org console

HardCodeStuds
  • 407
  • 2
  • 11
  • 29
  • 1
    You'd have to be an advanced programmer to tackle such a complicated problem, IMO. – Brett Nov 07 '13 at 21:42
  • Various languages can be embedded in C#. [IronPython](http://ironpython.net/), [NLua](https://github.com/NLua/NLua), [C# with CodeDOM](http://stackoverflow.com/questions/826398/is-it-possible-to-dynamically-compile-and-execute-c-sharp-code-fragments), etc... – Mike Nov 07 '13 at 21:42
  • How about using an interpreted language for the game, such as javascript or python? – Sam I am says Reinstate Monica Nov 07 '13 at 21:42
  • 1
    Have you looked at Roslyn? http://msdn.microsoft.com/en-gb/vstudio/roslyn.aspx Also check out scriptcs: http://scriptcs.net/ – Jon Skeet Nov 07 '13 at 21:45
  • i think you guys misunderstood me, i don't want a language to develop the game, i want a syntax and semantics analyzer for some given input. the game i'm already developing it in unity with C# scripts – HardCodeStuds Nov 07 '13 at 21:48
  • You probably want to create your own lexical/semantic analyzer specific for your game. – 123 456 789 0 Nov 07 '13 at 21:56
  • This sounds like a lot of complexity to teach the basics of programming. – Lee Taylor Nov 08 '13 at 16:37

2 Answers2

1

The Roslyn project from Microsoft is probably of interest to you. It lets you write an interactive command-line for C#.

ehdv
  • 4,483
  • 7
  • 32
  • 47
0

So the user input looks like if (IsPlatformAhead("2 meters")) Jump(); right? I think you should use in fact something more serious than just a parser, simply because user could write a valid query like this:

var platform = IsPlatformAhead("2 meters");
if (platform)
  Jump();

You need not only to parse but to execute the query. Either you use something from MS (Roslyn) or you use Mono (open source).

greenoldman
  • 16,895
  • 26
  • 119
  • 185