Question

Examples of specifying tokens Example 1. Keyword Keyword is if, else, for, or Regular expression Example 2. Comparison

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(1)Keyword "If" ::-

(a)It is a statement in any programming languages.

(b)It evaluates expression.

(c)If expression result is nonzero, that means it is True.

(d)If expression result is zero, that means it is False.

Syntax of if statement::-

if(expression)

{

//Do something

}

(2)Keyword "else":  

(a)else is also statement, It always comes with if statement.

(b)Whenever if statement is not true then else will get executed.

Syntax of else statement::-

if(expression)

{

//Do something

}

else

{

//do something

}

(3)Keyword "for"::- A for loop is a control structure that allows us to write a loop that needs to execute a specific number of times.

Sytanx::-

for ( start; condition; increment ) {
   statement(s);
}

start::- Need to specify starting point.

condition::- Need to specify expression,which control the the loop.

increment::-Need to specify expression which will increment or decrement the value so that loop should not go in infinite loop.

(4)Regular Expression::-

Regular Expression is a sequence of character which will used for pattern matching from any strings.

How to write regular expression::-

(a)Repeater::- (* , + and { }) all symbols are repeater, which particular character is coming multiple times in pattern then we should use repeater.

(b)The asterisk symbol ( * ) when particular character is coming 0 or multiple times then we should use *

(c)The Plus symbol ( + )when particular character is coming 1 or multiple times then we should use +

(d)Wildcard – ( . ) any character can be used any number of times.

(e)Optional character – ( ? )

(f)The caret ( ^ ) symbol: Start of the string.

(g)The dollar ( $ ) symbol:End of the string.

(5)(a)">" ::- Greater than

Ex::- if (10> 5){

printf("yes")

}

(b)"<" ::-Less than

Ex::- if (5<10){

printf("yes")

}

(c)"<=" ::Less than or equal to

Ex::-

f (10<=10){

printf("yes")

}

(d)">=" ::Greater than or equal to

Ex::-

f (10>=10){

printf("yes")

}

  

Add a comment
Know the answer?
Add Answer to:
Examples of specifying tokens Example 1. Keyword Keyword is "if", "else", "for", or Regular expre...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Module Answer one part and leave the rest for other students. When giving examples, give one example and let someone else give another example. Trivial answers such as "cool" or "l ag...

    Module Answer one part and leave the rest for other students. When giving examples, give one example and let someone else give another example. Trivial answers such as "cool" or "l agree" do not count. Civil discourse only, please. Inappropriate comments result in a loss of credit for this discussion. To enter an algebraic expression, equation or a function use the fx icon above. If it is not visible select the "Show More" down arrows on the left First Question:...

  • Here is the code I have so far. I'm trying to figure out how to implement...

    Here is the code I have so far. I'm trying to figure out how to implement a boolean and use precedence. The 2nd expression should be 14 but it comes out as 28 so I'm definitely not understanding. #include <stack> #include <iostream> #include <string> using namespace std; // Function to find precedence of // operators. int precedence(char op) {    if (op == '+' || op == '-')        return 1;    if (op == '*' || op ==...

  • Use the Python “re” module to do the following: 1. Write a regular expression pattern that matche...

    Use the Python “re” module to do the following: 1. Write a regular expression pattern that matches string “March 1, 2019, Mar 1, 2019, March First, 2019, March First, 19”. No credit for not using special characters: “*,+,?, | and etc” to do the matching. 2. Write a regular expression pattern that matches strings representing trains. A single letter stands for each kind of car in a train: Engine, Caboose, Boxcar, Passenger car, and Dining car. There are four rules...

  • The code below accepts and evaluates an integer expression with the following operators: +, _, *,...

    The code below accepts and evaluates an integer expression with the following operators: +, _, *, and /. Your task is to modify it to include the % remainder operator that has the same precedence as * and /. No need to rewrite the entire program, just insert the needed statements. import java.util.Stack; public class EvaluateExpression { public static void main(String[] args) {     // Check number of arguments passed     if (args.length != 1) {       System.out.println(         "Usage:...

  • EXERCISES: if & if...else STATEMENTS: Name Examples of if and if-else statements: Write an if statement...

    EXERCISES: if & if...else STATEMENTS: Name Examples of if and if-else statements: Write an if statement that multiplies payRate by 1.5 iſ hours is greater than 40. Write variable declarations for the variables payRate and hours first. Hint: Look for keyword if first, your boolean comes after the keyword [. This translates into Java as: double hours, payRate; if (hours > 40) { //{-} are optional here but I recommend that you them payRate = payRate 1.5; pay Rato pay...

  • 3. Create a CFG describing regular expressions over the alphabet {0, 1}. You will need to quote the regular expression operators and the template given you has them quoted as terminals. We expect the...

    3. Create a CFG describing regular expressions over the alphabet {0, 1}. You will need to quote the regular expression operators and the template given you has them quoted as terminals. We expect the grammar to generate the following syntactic constructions: • Union via "|", for example, 0 1 "|" 1 should be in the language generated by the grammar • Intersection via "&", for example, 0 1 "&" 1 should be in the language • Concatenation: any nonempty sequence...

  • Regular Expression processor in Java Overview: Create a Java program that will accept a regular expression...

    Regular Expression processor in Java Overview: Create a Java program that will accept a regular expression and a filename for a text file. The program will process the file, looking at every line to find matches for the regular expression and display them. Regular Expression Format The following operators are required to be accepted: + - one or more of the following character (no groups) * - zero or more of the following character (no groups) [] – no negation,...

  • You are to write a program name expressionTree.java that evaluates an infix expression entered by the...

    You are to write a program name expressionTree.java that evaluates an infix expression entered by the user. The expression may contain the following tokens: (1) Integer constants (a series of decimal digits). (2)   One alphabetic character - "x" (representing a value to be supplied later). (3)   Binary operators (+, -, *, / and % (modulo)). (4)   Parentheses          You will parse the input expression creating an expression tree with the tokens, then use the postOrder tree traversal algorithm to extract...

  • Programming Languages Final Exam Name: Question 1 (15 points) Give a regular expression for each of...

    Programming Languages Final Exam Name: Question 1 (15 points) Give a regular expression for each of the following languages over = {0,1,2). 1. All strings that begin with 1 and end with 2. 2. All strings that contain exactly three 1's. For example, "0101012" is valid. 3. All strings in which the digits are non-decreasing. For example, "002" is valid, but "102" is not.

  • I NEED SAMPLE PRINT OUT AS WELL AS CODE PLEASE!!!! Objectives: To gain experience with stacks....

    I NEED SAMPLE PRINT OUT AS WELL AS CODE PLEASE!!!! Objectives: To gain experience with stacks. Documentation: Explain the purpose of the program as detail as possible - 8%. Develop a solution for the problem and mention algorithms to be used -12% List data structures to be used in solution. - 5%. Give a description of how to use the program and expected input/output - 5% Explain the purpose of each class you develop in the program. - 5%. Programming:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT