Deprecated: Implicit conversion from float-string "1524928196.421" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1524928196.421" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1524928196.421" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1524928196.421" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1524928196.421" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1524931105.892" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1524931105.892" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1524931105.892" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1524931105.892" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1524931105.892" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1524971168.034" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1524971168.034" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1524971168.034" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1524971168.034" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1524971168.034" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1524974531.117" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1524974531.117" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1524974531.117" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1524974531.117" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1524974531.117" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1524929023.115" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1524929023.115" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1524929023.115" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1524929023.115" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1524929023.115" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594
Compiler Design: [Compiler] Identify phase of error
retagged by
1,447 views
1 votes
1 votes
int a = b+*/c;

Which phase will give the error?Lexical or syntax?

retagged by

1 Answer

3 votes
3 votes

Syntax error

1)Lexical Error

  • It takes raw input which is a stream of characters and converts it into a stream of tokens which are logical units each representing one or more characters that b elong together

Typically  

Keywords; Examples-for, while, if etc.
Identifier; Examples-Variable name, function name etc.
Operators; Examples '+', '++', '-' etc.
Separators; Examples ',' ';' etc

identifier=letter$\left ( letter+digit \right )^{*}$

float=$digit^{+}.digit^{*}+.digit^{+}$

Here it's able to generate token so there is  No lexical error

  • total number of token =9

2)Syntax errors occur during the parsing of input code, and are caused by grammatically incorrect statements. Typical errors might be an illegal character in the input, a missing operator, two operators in a row, two statements on the same line with no intervening semicolon, unbalanced parentheses, a misplaced reserved word, etc. 

3)Semantic errors occur during the execution of the code, after it has been parsed as grammatically correct. These have to do not with how statements are constructed, but with what they mean. Such things as incorrect variable types or sizes, nonexistent variables, subscripts out of range, and the like, are semantic errors.

http://infolab.stanford.edu/~ullman/dragon/slides1.pdf

edited by

Related questions


Deprecated: Implicit conversion from float-string "1673549164.828" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1673549164.828" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1673549164.828" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1673549164.828" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803
4.3k
views
1 answers
3 votes
radha gogia asked Mar 11, 2018
4,282 views
1. Declaring an array with a floating point subscript : e.g int a[2.8] ;In my opinion ,it should be a syntax error :How will the parse tree be generated ...
2.6k
views
3 answers
2 votes
pC asked Nov 19, 2015
2,647 views
583
views
2 answers
1 votes
Souvik33 asked Jan 12, 2023
583 views
What is the earliest stage compiler error for the following C code snippet:int x = @33;Lexical ErrorSyntax ErrorSemantic ErrorNone
1.1k
views
2 answers
10 votes
shubhams3 asked Mar 22, 2016
1,078 views
a = 1+1+1+ 1+1+1 1+1;as far as i think, it will pass the lexical phase.. it should b syntax error.. correct ??