LANGUAGE RULES- Compiler

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/12

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:31 AM on 4/27/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

13 Terms

1
New cards

Can 'break' be used inside loops in PORTIA?

NO. 'break' is ONLY valid inside switch case blocks. Not supported in for, while, or do-while loops.

2
New cards

Can void functions have parameters?

NO. The PORTIA grammar forbids it. Use func int with return 0 as a workaround for logically void recursive functions.

3
New cards

Is 0.0 a valid double literal?

NO. PORTIA requires a minimum of 8 total digits. 0.0 has only 2. Minimum valid: 0.00000000. Enforced at RUNTIME, not by the lexer.

4
New cards

Can you declare local variables inside a switch case block?

NO. All variables must be declared at the top of the function body before the switch. You can only assign to pre-declared variables inside case blocks.

5
New cards

Can weave fields be arrays?

NO. Weave fields can only be primitive types. The CFG production <field_dec> => <dtype> id ; only allows primitives — no array declarations inside weaves.

6
New cards

Do you need 'using' to call another function?

NO. Functions are always callable without using. Only global variables and constants require explicit using binding.

7
New cards

Do weave types need 'using' to be referenced?

NO. Weave types are always visible inside functions without using.

8
New cards

Why does PORTIA require 'using' for global variables?

Explicitness. Prevents accidental global state modification. When you see "using counter", the dependency is visible in the code. Similar to import statements — no hidden side effects.

Framework: WHAT = explicit binding. WHY = no hidden global access.
EXAMPLE: using total;

9
New cards

const vs var — initialization rule?

var can use expressions (= 5 + 3). const must use literals only (= 100).
Both need using to access globals inside functions.

10
New cards

Maximum identifier length?

25 characters. States s231–s276 = valid. States s277–s280 = error states for a 26th character.

11
New cards

What escape sequences are valid in PORTIA?

\n (newline), \t (tab), " (double quote), ' (single quote). Valid in both string and char literals.

12
New cards

Char literal valid range?

Single printable ASCII — code points 32 to 126. Escape sequences \n \t " ' are also allowed.

13
New cards

Does PORTIA have a string length built-in?

Yes — len(str) returns the length as an int. It's a built-in function, not a method. abs, sqrt, and pow are the other three built-ins.