Conception: Write a simple interpreter with C #
I don't know what to use, play.
Design a simple language (essentially the syntax of PASCAL) is specifically used to draw. The interpreter is running on the server side, and the user edits the source program on the browser to pass the interpretation on the server. The server dynamically creates a picture back to the client.
Provide common-purpose drawing functions (Line, Moveto, Lineto, Fill ...) Provide common math functions (SIN, COS ...) to provide common operators ( - * /) to calculate coordinate users to define variables (temporary Integer) Implementing the assignment statement Implementing the other statement of the for loop and saying that it is still not intended to let the user define local variables.
Textual Law: Program :: [Statement ...] Statement :: [Cycle / Assignment / Defined Variable / Command] Cycle: For Ident: = Expression TO Expression DO Statement Assignment :: Ident: = Expression; Defining Variables: : Ident: Type; Command :: Command Name ([Expressions,] ...); Expressions: [ /-] Item [ /- Item] ... Item :: Facts [* // Factor] Factor :: Digital / Variable / (Expression)
Later, I thought that the following grammar description should be better than some command and functionality only is that the command is built-in.
Procedure :: Variable Statement part of the function declaration part of the program segmentation variable declaration section: [Variable declaration] ..... Variable declaration :: Variable Name: Type [= number]; function declaration part :: [function declaration / process declaration ] ... function declaration :: function function name (parameter list): Return Value Begin program segment END; process declaration :: Procedure Process Name (Parameter List) Begin program segmentation END; program segmentation :: Begin [Statement] ....... End; statement :: [loop / assignment / command / function] loop :: for ident: = Digital to digital DO statement assignment :: Ident: = expression; command :: Command name (Parameter list); function :: function name (parameter list); expression :: [ /-] Item [ /- Item] ... Item :: Facts [* // Factor] Factor :: Digital / Variable /(expression)
The relationship between variables and values can be stored with hash, what should the function do? Record the location defined by the function, then wait for the call to find the definition to continue running? It seems to be the case. The parameter list uses a structural array, the relationship between the function name and the parameter list is used with a hash table. OK is doing this.
I hope to have a friend who knows the principle of compilation.