Question: Write a program (in F#) which: 1. Accepts: a. A space-delimited set of symbols representing a sentence described by the grammar. (The user should
Write a program (in F#) which: 1. Accepts: a. A space-delimited set of symbols representing a sentence described by the grammar. (The user should simply be prompted for the input to be entered via keyboard.) 2. Outputs: a. For successful parsing: "The Sentence follows the grammar." b. For unsuccessful parsing: "The Sentence is incorrect because: " BNF for parser-Just the core grammer from chapter 2 (without the if and while extensions... though they are almost trivial to add). program stmt_list stmt_list $$ stmt stmt_list | stmtid := expr | read id | write expr expr term term_tail term_tail add_op term term_tail | term factor factor_tail factor_tail factor add_op mult_op mult_op factor factor_tail | (expr) | id | number + | | /
Step by Step Solution
3.39 Rating (146 Votes )
There are 3 Steps involved in it
open System type Token Id of string Assign Read Write OpenParen CloseParen Number of int Plus Minus Times Divide EndOfString type ParserResult Success of string Failure of string type ParserState toke... View full answer
Get step-by-step solutions from verified subject matter experts
