Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

C3 Programming Language

Cortez, Mary Grace V. Dasmarias, Camille B. Dio, Valerie C. BSCS 4-3

C3 Programming Laguange is a general-purpose functional programming language inspired by metalanguage (ML).

I- Character Set Letters A-Z, a-z Digits 0-9 Special Characters Space + - * / ^ \ () [] {} = != <> $ , ; : % | & ? _ # @ ~ II- Identifiers An identifier is a letter followed by any combination of letters (a...z or A...Z), numbers and underscores ("_"). Identifiers are case-sensitive, and cannot be identical to any keyword. Identifiers are the valid names that can be given to variables. III- Operation Symbols Arithmetic Operation Meaning + Addition Subtraction * MultipliPcation / Real Division Div Integer Division Mod Modulo , Seperation ~ Negative Sign Operators Meaning and Logical And or Logical Or not Logical Not is assignment Relational Operators = <> < <= > >= Meaning Equal to Not equal to Less than Less than or equal to Greater than Greater than or equal to

V- Noise Words Symbol \t \n \r \\ Meaning Tab New Line Carriage Return Single \

IV- Keywords and Reserved Words Reserved words prt get if ... else func Return Data Type bool int real char str VI- Comments Comments should be written (** like this **). VII- Blanks/ Spaces Whitespace is ignored except as it serves to separate identifiers and keywords. Whitespace includes all spaces, tabs, and new lines. New lines may be of the form found on any system. VIII- Delimiters & Brackets Symbol { } [ Meaning Left brace, function delimiter Right brace, function delimiter Left bracket, switch case delimiter Meaning Output Input Condition Function Return statement Meaning Integers Real numbers Characters Not the same as list of characters

Values True, false 0, 1, 30, ~1 0.0, 1.2, ~2.30 #a, #\n hello, , hi there

] Right bracket, switch case delimiter ( Left parenthesis ) Right parenthesis and Double Quotation Mark commonly used to denote string literal (** **) Comment line ; End of line IX- Free and Fixed Formats
<output> :: = prt (<output statement>); <input> :: = get (<identifier>); <assignment> :: = <identifier> : = <new value> <if statement> :: = if <condition> els <expression> <if-els if statement> :: = if <condition> els if <condition> den <expression> esl <expresion> <do-while> :: = while <condition> do <expression>

X- Expressions Expression if a else y a and b, a or b x+y, x-y, x*y x<y x=y x/y i^j Types Result Type Comments a of type bool, x, y are statements same as x,y a, b of type bool x,y either both int or both real x,y either both int or both real x,y of same equality type x,y of type real i,j of type string Bool same as x,y Bool Bool Real String &&, || Overloaded operators Overloaded operators Real division Concatenation

XI- Statements
a.) Input and Output Statements Syntax: <output> :: = prt (<output statement>); <input> :: = get (<identifier>); Example: prt ("Enter a string: "); var is get (); b.) Assignment Statements: define or redefine a symbol by assigning a value to it. Syntax: <assignment> :: = <identifier> : = <new value> Example:

n := 1; c.) Condition Statements: controls the sequence of the statements, depending upon the condition. Syntax: <if statement> :: = if <condition> else <expression> <if-els if statement> :: = if <condition> else if <condition> <expression> else <expresion> Example: (if statement) if x > 0 den prt ("pos \n"); else (); (if-els if) if (x > 0) prt ("pos"); els if (x < 0) prt ("neg"); else prt ("zero"); d.) Iteration Statements: creates a loop of code to execute a block of code as long as the condition evaluates to a Boolean value of true. Syntax: <do-while> :: = while <condition> do <expression> Example: (do-while) counter := 1; while (!counter < 10) do { counter := !counter + 1; prt Hello; }; e.) Comment Statements: are used to keep parts of a script from being read. Syntax: (* Comment here *) Example: (* * This * is a * block comment *) (* line comment*) f.) Declaration Statement: are used to declare variables and can initialize the variable with a value. Syntax: <declaration> ::= fun <identifier> <identifier> = <expression> (function binding)

Example: (function binding) func succ n = n+1 func fact n = if (n<2) val+1; else n * (~1); func f (x,y) = 2*x+y int func start() { str temp; prt (Hello World,val); temp is get(); } Int func add(int a, int b0 { return is a+b; }

You might also like