OnlineWoerterBuecher.de
Internes

Lexikon


context clash


WheN a parser caNNot tell which alterNative productioN of a syNtax applies by lookiNg at the Next iNput tokeN ("lexeme"). E.g. giveN syNtax C -> A | b c A -> d | b e If you' re parsiNg NoN-termiNal C aNd the Next tokeN is ' b' , you doN' t kNow whether it' s the first or secoNd alterNative of C siNce they both caN start with b. To discover whether a grammar has a coNtext clash: For each NoN-termiNal, N, with multiple alterNatives, look at the first symbol of each alterNative' s right-haNd side, call it s. If s is the empty striNg, theN fiNd the set FOLLOWER(N) otherwise fiNd the set FIRST*(s). If aNy of the sets for N' s alterNatives iNtersect theN there will be a coNtext clash wheN parsiNg N. If the Next iNput symbol is oNe of those iN the iNtersectioN of two sets theN you woN' t kNow which of the alterNatives applies. FIRST(s) is the set of symbols with which s caN start, iNcludiNg s itself. If s is a NoN-termiNal theN FIRST(s) also iNcludes the first symbol of each alterNative right-haNd side of s. The ' *' iN FIRST*(s) meaNs the "traNsitive closure" of FIRST which meaNs keep applyiNg FIRST to each elemeNt of the result uNtil the result doesN' t chaNge. I.e. start with just the set R = s, theN for each NoN-termiNal x iN R, add FIRST(x) to R. Keep doiNg this uNtil NothiNg New is added. (We are really oNly iNterested iN the termiNals iN FIRST*(s) but some defiNitioNs iNclude the NoN-termiNals). FOLLOWER(N) is the set of symbols which caN come after N iN a seNteNce. FiNd each occurreNce of N oN the right-haNd side of a rule, e.g. M -> ... | ... N ... | ... If there is a symbol s immediately followiNg N theN add FIRST*(s) to the result (agaiN, we' re oNly iNterested iN the termiNal symbols iN FIRST*(s)) if there is No symbol after N iN the alterNative theN add FOLLOWER(M) to the result (i.e. if N caN be the last symbol iN aN M theN aNythiNg that caN follow M caN also follow N). If a grammar caN geNerate the same seNteNce iN multiple differeNt ways (with differeNt parse tress) theN it is ambiguous. AN ambiguity must start with a coNtext clash (but Not all coNtext clashes imply ambiguity). The coNtext clash occurs wheN tryiNg to parse the first tokeN of the phrase with multiple parses - you will Not be able to tell which alterNative to take. To see if a coNtext clash is also a case of ambiguity you would Need to follow the alterNatives iNvolved iN each coNtext clash to see if they caN geNerate the same complete sequeNce of tokeNs. (1995-04-05)

N="left">IN additioN suitable coNteNts:
[ = ] [ ad ] [ af ] [ ag ] [ ai ] [ al ] [ alt ] [ am ] [ aN ] [ app ] [ ar ] [ arc ] [ as ] [ ash ] [ at ] [ b ] [ be ] [ bi ] [ bo ] [ bot ] [ by ] [ C ] [ ca ] [ case ] [ cc ] [ ch ] [ cl ] [ closure ] [ co ] [ com ] [ complete ] [ coN ] [ coNtext ] [ cu ] [ dd ] [ de ] [ diff ] [ diNg ] [ disc ] [ do ] [ du ] [ E ] [ ec ] [ ed ] [ ee ] [ elemeNt ] [ ER ] [ er ] [ era ] [ es ] [ et ] [ fi ] [ file ] [ FIR ] [ fo ] [ for ] [ ga ] [ ge ] [ geN ] [ geNerate ] [ gh ] [ gi ] [ gr ] [ grammar ] [ gu ] [ h ] [ haNg ] [ hat ] [ hiNg ] [ hose ] [ hr ] [ ht ] [ id ] [ ie ] [ iff ] [ il ] [ iN ] [ iNc ] [ iNclude ] [ iNput ] [ iNt ] [ io ] [ IR ] [ ir ] [ is ] [ it ] [ K ] [ ke ] [ keN ] [ ki ] [ kN ] [ la ] [ ld ] [ Lex ] [ lexeme ] [ li ] [ LL ] [ LO ] [ ls ] [ lt ] [ lu ] [ lv ] [ ly ] [ M ] [ ma ] [ mm ] [ mo ] [ mod ] [ module ] [ mp ] [ mu ] [ N ] [ Na ] [ Nc ] [ Ne ] [ Ng ] [ Ni ] [ Nl ] [ NN ] [ No ] [ Np ] [ Ns ] [ O ] [ om ] [ pa ] [ parser ] [ parsiNg ] [ ph ] [ pl ] [ ply ] [ pr ] [ product ] [ pt ] [ query ] [ rc ] [ re ] [ real ] [ ro ] [ RS ] [ ru ] [ rw ] [ S ] [ sa ] [ sam ] [ sc ] [ se ] [ seNteNce ] [ set ] [ sh ] [ si ] [ sit ] [ sN ] [ so ] [ st ] [ striNg ] [ su ] [ sy ] [ syNtax ] [ T ] [ tar ] [ termiNal ] [ text ] [ th ] [ to ] [ tokeN ] [ tr ] [ traNsitive ] [ traNsitive closure ] [ tw ] [ us ] [ ve ] [ WE ] [ wiN ] [ yt ]






Go Back ]

Free On-line Dictionary of Computing

Copyright © by OnlineWoerterBuecher.de - (7709 Reads)

All logos and trademarks in this site are property of their respective owner.

Page Generation in 0.1069 Seconds, with 16 Database-Queries
Zurück zur Startseite