Skip to content

ZephyrusZhang/splc

Repository files navigation

splc

Features

Data Types

  • int: decimal or hexadecimal, signed

  • float: only dot form

  • char: normal character or hex-form character

  • struct

  • pointer: int * float *``char *. & for addressing, * for address resolution

Control Flow

  • if, else if, else

  • while

  • for

  • break, continue

Comment

  • single line comment: //
  • multiple line comment: /* */

Pre-process

  • #include

Error recognizing

  • Lexical error (error type A) when there are undefined characters or tokens in the SPL program, or identifiers starting with digits.

  • Syntax error (error type B) when the program has an illegal structure, such as missing closing symbol. Please find as many syntax errors as possible.

Semantic Analysis

Error Type

  • Type 1 a variable is used without a definition

  • Type 2 a function is invoked without a definition

  • Type 3 a variable is redefined in the same scope

  • Type 4 a function is redefined (in the global scope, since we don’t have nested functions)

  • Type 5 unmatching types appear at both sides of the assignment operator (=)

  • Type 6 rvalue appears on the left-hand side of the assignment operator

  • Type 7 unmatching operands, such as adding an integer to a structure variable

  • Type 8 a function’s return value type mismatches the declared type

  • Type 9 a function’s arguments mismatch the declared parameters (either types or numbers, or both)

  • Type 10 applying indexing operator ([...]) on non-array type variables

  • Type 11 applying function invocation operator (foo(...)) on non-function names

  • Type 12 array indexing with a non-integer type expression

  • Type 13 accessing members of a non-structure variable (i.e., misuse the dot operator)

  • Type 14 accessing an undefined structure member

  • Type 15 redefine the same structure type

  • break or continue statement not within loop

  • dereference of a non-pointer

  • 32-bit signed integer overflow

  • hex char literal overflow

  • non-boolean expression at the conditional statement

Other Feature

  • forced type conversion
  • return type guess of an undefined function

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •