-
Notifications
You must be signed in to change notification settings - Fork 12
Syntax Analyzer
Harpinder edited this page Feb 13, 2020
·
21 revisions
- Eliminate left recursion (both immediate and non-immediate {Algo on page 213 TB}) , left factoring (pg 215)
- Top down parser can't parse left recursive grammars.
- A -> B | C me follow(A) includes follow(B) also ?
- No
- Are global variables allowed?
- No
- A declaration stmt can appear anywhere in the program. But everything according to grammar should be within a module
- cannot appear, variable declaratn in modules only
- print(arr[2]) not allowed in grammar {print only allows arr[ID] }
- is allowed , modify grammar accordingly
- get_value() does not allows to take arr[i]/arr[2] as input
- not allowed, only id allowed
- AND and OR have same precedence
- Arithmetic expressions grammar does not maintain precedence
- declare a:integer, b:real ; allowed? Grammar does not
- not allowed
- Function declarations saari ek saath upar hi ayengi?
- ha
- Function ke input parameters me array me variable indices allowed? {global variables toh hai hi, but grammar does not allows this}
- yes fun(int a, int b, arr[a..b]) syntactically valid
- array declaration ki grammar does not allow variable indices .. (whichID me ana chahiye instead of ID)
- 0 input parameters allowed in function definition? { grammar does not allows }
- not allowed
- idList,booleanExpr,inpList,outpList,artithmeticExpr,term, me left recursion
- TRUE/FALSE are boolean expressions or not?
- yes
- Left associativity hat jayegi when u remove left recursion.
- it can be implemented through right recursive grammar
- traversal ka tareeka change karna hoga
- Boolean expr rule is ambiguous
- switch(2 | arr[i] | arr[3] | {expression evaluating to a number} ) allowed or not
- not allowed, only id
- rule doesn't have any base case
- khud se daalo
- Language specification says 2 cases should be separated by a break, so last case me break rakhega kya?
- yes
- range me numop hoga kya?
- yes
- expr -> arith | bool
- left factoring hi hai
- Rule 30, 33 thik
- Sample test cases parse karne hai
Final Grammar with First and Follow Sets