Questions tagged [ambiguity]

9 questions
14
votes
11 answers

Should programming languages be strict or loose?

In Python and JavaScript, semi-colons are optional. In PHP, quotes around array-keys are optional ($_GET[key] vs $_GET['key']), although if you omit them it will first look for a constant by that name. It also allows 2 different styles for blocks…
mpen
  • 1,889
  • 19
  • 29
14
votes
2 answers

What does scannerless parsing have to do with the "Dangling Else Problem"?

I do not understand this sentence from the Wikipedia article on the Dangling Else problem: [The Dangling Else problem] is a problem that often comes up in compiler construction, especially scannerless parsing. Can someone explain to me how…
user39685
13
votes
11 answers

Is there a universal date format that anyone in the world can understand?

In Canada, everyone is familiar with the date format YYYY-MM-DD. In Europe or South Africa, they prefer DD-MM-YYYY. There are users from South Africa who get confused with the YYYY-MM-DD date format. Is there a way to handle this situation? I was…
Thierry Lam
  • 1,108
  • 2
  • 11
  • 17
11
votes
2 answers

Dijkstra's example of an ambiguous program

Salutations. Dijkstra wrote that even a few lines of seemingly simple code could be hopelessly ambiguous. In at least one work, which I can't find now to save my life, he gave a little example program to demonstrate this ambiguity. Can anybody point…
4
votes
2 answers

Ambiguity in method overloading

The book I am reading on Java states something confusing and unacceptable. Learning About Ambiguity When you overload methods, you risk creating an ambiguous situation - one which the compiler cannot determine which method to use. For example,…
With A SpiRIT
  • 201
  • 2
  • 3
  • 9
3
votes
2 answers

In the usual "3-layer" architecture pattern, where would one best create dynamic, user-readable strings?

I've been trying to build this (principally desktop, but could eventually be turned into a cloud app) document editor program for a while and have it laid out using the broad principles of the 3-Layer (Data, Model, and UI) and MVC…
3
votes
1 answer

Showing a grammar is ambiguous

I have the following question taken from a compilers course exam: Show that the following grammar is ambiguous. S = XcY X = a Y = b | Z Z = bW W = d | ϵ I drew the following tree: Am I correct in thinking it is ambiguous because acY can end up at…
TomSelleck
  • 379
  • 3
  • 11
2
votes
2 answers

Convert grammar into an LL(1) grammar which recognises the same language

I have the following sample question for a compilers exam and wanted to check my solution. Convert the following grammar into an LL(1) grammar which recognises the same language: E -> E + T E -> T T -> id T -> id() T -> id(L) L -> E;L L ->…
TomSelleck
  • 379
  • 3
  • 11
2
votes
1 answer

Verification as QA - makes sense?

Preparing my thesis, I found another interesting discrepancy. While some books say verification it terms of static analysis of work products is quality control (looking for defects), other say it is actually quality assurance because the process of…
John V
  • 4,898
  • 10
  • 47
  • 73