GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
101 views

MISSPELLING OF KEYWORDS CAUSE WHICH TYPE OF ERROR- SYNTAX ERROR OR LEXICAL ERROR??

printf("%d") without any integer argument will cause which type of error??

asked in Compiler Design by Veteran (11.5k points) 6 62 146
edited by | 101 views
not sure but should be syntax-error
Misspelled keyword give syntax error eg for misspelled to fro give syntax error but for lexical phase it is a token

1 Answer

+2 votes
Best answer

Misspelling of keywords mean it will be treated as an identifier by a compiler..As there is only change in spelling of keyword , so it is considered to be a valid token because this satisfies the pattern as needed by dfa of lexical analyser..

It is not a syntax error either as syntax error is something which is related to violation of grammar by any of the statements..

Now say int is mistakeably written as 'inta' ..Now it is identified as an identifier..But its type is not mentioned as there is no "int" in declaration part..Hence it will be a type checking error which is related to semantic phase..

 

As far as the statement   "printf("%d)" is concerned , it will neither give compilation error nor give runtime error. It will give a valid output..For more clarification on this query , plz check the following :

https://stackoverflow.com/questions/437816/behaviour-of-printf-when-printing-a-d-without-supplying-variable-name

answered by Veteran (87k points) 15 57 292
selected by
thanx a lot sir. :)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Top Users Oct 2017
  1. Arjun

    23210 Points

  2. Bikram

    17018 Points

  3. Habibkhan

    6652 Points

  4. srestha

    5864 Points

  5. Debashish Deka

    5430 Points

  6. jothee

    4908 Points

  7. Sachin Mittal 1

    4762 Points

  8. joshi_nitish

    4274 Points

  9. sushmita

    3954 Points

  10. Silpa

    3698 Points


Recent Badges

Regular Juhi Sehgal
Popular Question vineet.ildm
Nice Comment Arjun
100 Club vipul verma
Notable Question jothee
Popular Question jothee
Nice Question shivangi5
Regular rinks5
Notable Question shipra tressa
Regular sasi
27,247 questions
35,056 answers
83,703 comments
33,183 users