Context Free Grammar

Tags:

By: Aaron Jencks

Views: 2819
Posted on:

March 17, 2023, 1:47 a.m.

Please login to vote!

0 👍 0 👎

Below I've attached the Context Free Grammar (CFG) of Battle Turing's custom language. It's going to be used in the top-down parser that I'm going to create soon.

Start symbol: S

  • S → E;S | FS | ɛ
  • E → left L | right L | >> L | << L | write [literal] | halt | accept | reject | start | goto identifier
  • R → ifHMJ | whileHT
  • F → identifier:B | R
  • B → {S}
  • H → (X)
  • T → {U}
  • X → O Y | true | false | & X X | | X X | ! X
  • O → = | != | < | > | <= | >=
  • Y → N N | [integer] [integer]
  • N → ^ | read | [literal]
  • U → E;U | break;U | continue;U | IU | ɛ
  • I → ifHTK | whileHT
  • J → elseM | ɛ
  • K → elseT | ɛ
  • L → [integer] | ɛ
  • M → {P}
  • P → E;P | RP | ɛ

This was made by using Stanford's CFG Developer https://web.stanford.edu/class/archive/cs/cs103/cs103.1156/tools/cfg/

Comments

You are not logged in, please log in here to comment

Current Comments