Identifiers and Literals
Identifiers
An identifier is a name for a variable or function. In Lipi, identifiers must follow these rules:
- Must start with a letter or underscore
- Can contain letters, numbers, or underscores
- Cannot be a reserved keyword
- Cannot contain spaces or special characters
Examples of valid and invalid identifiers:
purna count; :) Valid identifier
purna _count; :) Valid identifier
purna count123; :) Valid identifier
purna 123count; :) Invalid - starts with a number
purna my-var; :) Invalid - contains hyphen
purna my var; :) Invalid - contains space
purna if; :) Invalid - reserved keywordLiterals
Literals are fixed values that appear directly in the code. Lipi supports the following types of literals:
- Number: An integer or decimal value (e.g., 42, 3.14)
- String: A sequence of characters enclosed in double quotes (e.g., "Sample text")
- Character: A single character enclosed in single quotes (e.g., 'A')
Examples of literals:
purna num; :) Integer variable declaration
dasa pi; :) Decimal variable declaration
akshar grade; :) Character variable declaration
paath name; :) String variable declaration
num = 42; :) integer literal
pi = 3.14; :) decimal literal
grade = 'A'; :) character literal
name = "John"; :) string literal
Next Steps
Now that you understand identifiers and literals in Lipi, you can learn more about: