Что такое Синтаксический анализ/парсинг? [закрытый]

поле таблицы - prdocutcode, почему вас зовут только код, замените код под моим кодом

 <input type="hidden" name="productCode" value="<?php echo $product['productCode']; ?>">
35
задан Eric Leschinski 16 February 2014 в 22:40
поделиться

3 ответа

You could say that parsing a string of characters is analyzing this string to find tokens, or items and then create a structure from the result.

In your example, calling Integer.parseInt on a string is parsing this string to find an integer.

So, if you have:

String someString = "123";

And then you invoke:

int i = Integer.parseInt( someString );

You're telling java to analyze the "123" string and find an integer there.

Other example:

One of the actions the java compiler does, when it compiles your source code is to "parse" your .java file and create tokens that match the java grammar.

When you fail to write the source code properly ( for instance forget to add a ; at the end of a statement ), it is the parser who identifies the error.

Here's more information: http://en.wikipedia.org/wiki/Parse

55
ответ дан 27 November 2019 в 06:32
поделиться

Parsing is to read the value of one object to convert it to another type. For example you may have a string with a value of "10". Internally that string contains the Unicode characters '1' and '0' not the actual number 10. The method Integer.parseInt takes that string value and returns a real number.

String tenString = "10"

//This won't work since you can't add an integer and a string
Integer result = 20 + tenString;

//This will set result to 30
Integer result = 20 + Integer.parseInt(tenString);
35
ответ дан 27 November 2019 в 06:32
поделиться

From dictionary.reference.com:

Computers. to analyze (a string of characters) in order to associate groups of characters with the syntactic units of the underlying grammar.

The context of the definition is the translation of program text or a language in the general sense into its component parts with respect to a defined grammar -- turning program text into code. In the context of a particular language keyword, though, it generally means to convert the string value of a fundamental data type into an internal representation of that data type. For example, the string "10" becomes the number (integer) 10.

9
ответ дан 27 November 2019 в 06:32
поделиться
Другие вопросы по тегам:

Похожие вопросы: