MedVision ad

EBNF and Railroad Diagrams (1 Viewer)

SASH_06_X

Well-Known Member
Joined
Jun 5, 2023
Messages
441
Location
on my couch
Gender
Female
HSC
2023
I just can't seem to get these. I've looked through the textbook, three different sets of notes and youtube videos, but I still have almost 0% idea on how to intepret or draw them and every time I see them in a past paper, they look like Greek to me. Can someone please clarify the concepts?
 

SadCeliac

done hsc yay
Joined
Sep 23, 2021
Messages
2,490
Location
Sydney <3
Gender
Male
HSC
2023
I just can't seem to get these. I've looked through the textbook, three different sets of notes and youtube videos, but I still have almost 0% idea on how to intepret or draw them and every time I see them in a past paper, they look like Greek to me. Can someone please clarify the concepts?
I can try but I'll do it a bit later (doing bio rn)
 

STBAccuracy

Member
Joined
Jun 22, 2021
Messages
22
Location
Somewhere in Sydney
Gender
Male
HSC
2023
I'll try explain EBNF here,

Its basically the text version of Railroad to explain the syntax of a programming language (most HSC questions on EBNF would be to either interpret EBNF or translate given code into EBNF).

I'll run an example and indicate what each symbol means:

===============================================

The given EBNF (courtesy of Course Specifics)

Letter = A | B | C
Digit = 0 | 1 | 2 | 3| 4 | 5
Identifier = <Letter> {<Letter> <Digit>}

LET <Identifier> = <Identifier>

This portion of EBNF explains the syntax of how a variable can be defined.
  • LET <Identifier> = <Identifier> simply states the structure in which a variable must be defined with it's value.
  • <Identifier> with the <> indicates that this term is specifically defined elsewhere in the EBNF.
  • Identifier = <Letter> {<Letter> <Digit>}; the term Identifier without the <> indicates that the term is defined here.
    • I'll break down the line of EBNF here:
    • The code starting with <Letter> state that the Identifier must start with a Letter term (if you check the Letter definition it must be either the letter A, B or C).
    • Then it has non-terminal values in {}. Wavy brackets indicate that the value inside can be repeated 0 or more times.
      • If there are no repetitions then the Identifier can comprise of just a single letter.
      • If there are repetitions, it must follow the syntax within the brackets, noticeably <Letter> <Digit>, indicating that after the initial letter it must be followed by a letter then a digit.
      • If there are more than one repetition the syntax must be followed continually resulting in a pattern of <Letter> <Letter><Digit> <Letter><Digit>...
    • Thus a combination of Identifiers can be made with varying length with the repetition.
Some correct/valid definition of Identifier includes A, AB0, BA4, AA0A0 colourcoded the new repetitions of {}.

With these valid definition of Identifier, they can be used in the assignment statement of LET <Identifier> = <Identifier>, For example;
  • LET A = C
  • LET AB0 = AA0A0
  • LET BA4 = C
I used page 23 of the Course Specifics for the example above.

Please let me know if you still don't get it or if my explanation went on a tangent!
 

Attachments

SASH_06_X

Well-Known Member
Joined
Jun 5, 2023
Messages
441
Location
on my couch
Gender
Female
HSC
2023
I'll try explain EBNF here,

Its basically the text version of Railroad to explain the syntax of a programming language (most HSC questions on EBNF would be to either interpret EBNF or translate given code into EBNF).

I'll run an example and indicate what each symbol means:

===============================================

The given EBNF (courtesy of Course Specifics)

Letter = A | B | C
Digit = 0 | 1 | 2 | 3| 4 | 5
Identifier = <Letter> {<Letter> <Digit>}

LET <Identifier> = <Identifier>

This portion of EBNF explains the syntax of how a variable can be defined.
  • LET <Identifier> = <Identifier> simply states the structure in which a variable must be defined with it's value.
  • <Identifier> with the <> indicates that this term is specifically defined elsewhere in the EBNF.
  • Identifier = <Letter> {<Letter> <Digit>}; the term Identifier without the <> indicates that the term is defined here.
    • I'll break down the line of EBNF here:
    • The code starting with <Letter> state that the Identifier must start with a Letter term (if you check the Letter definition it must be either the letter A, B or C).
    • Then it has non-terminal values in {}. Wavy brackets indicate that the value inside can be repeated 0 or more times.
      • If there are no repetitions then the Identifier can comprise of just a single letter.
      • If there are repetitions, it must follow the syntax within the brackets, noticeably <Letter> <Digit>, indicating that after the initial letter it must be followed by a letter then a digit.
      • If there are more than one repetition the syntax must be followed continually resulting in a pattern of <Letter> <Letter><Digit> <Letter><Digit>...
    • Thus a combination of Identifiers can be made with varying length with the repetition.
Some correct/valid definition of Identifier includes A, AB0, BA4, AA0A0 colourcoded the new repetitions of {}.

With these valid definition of Identifier, they can be used in the assignment statement of LET <Identifier> = <Identifier>, For example;
  • LET A = C
  • LET AB0 = AA0A0
  • LET BA4 = C
I used page 23 of the Course Specifics for the example above.

Please let me know if you still don't get it or if my explanation went on a tangent!
Thank you for taking the time to provide such a detailed explanation, I really appreciate it! And also I think I finally get the concept, so thank you again for that!! :)
 

STBAccuracy

Member
Joined
Jun 22, 2021
Messages
22
Location
Somewhere in Sydney
Gender
Male
HSC
2023
Thank you for taking the time to provide such a detailed explanation, I really appreciate it! And also I think I finally get the concept, so thank you again for that!! :)
If you need further explanations on any of the other symbols of EBNF or help on questions let me know!

I'll try write something similar for railroad diagrams later today.
 

SadCeliac

done hsc yay
Joined
Sep 23, 2021
Messages
2,490
Location
Sydney <3
Gender
Male
HSC
2023
I'll try explain EBNF here,

Its basically the text version of Railroad to explain the syntax of a programming language (most HSC questions on EBNF would be to either interpret EBNF or translate given code into EBNF).

I'll run an example and indicate what each symbol means:

===============================================

The given EBNF (courtesy of Course Specifics)

Letter = A | B | C
Digit = 0 | 1 | 2 | 3| 4 | 5
Identifier = <Letter> {<Letter> <Digit>}

LET <Identifier> = <Identifier>

This portion of EBNF explains the syntax of how a variable can be defined.
  • LET <Identifier> = <Identifier> simply states the structure in which a variable must be defined with it's value.
  • <Identifier> with the <> indicates that this term is specifically defined elsewhere in the EBNF.
  • Identifier = <Letter> {<Letter> <Digit>}; the term Identifier without the <> indicates that the term is defined here.
    • I'll break down the line of EBNF here:
    • The code starting with <Letter> state that the Identifier must start with a Letter term (if you check the Letter definition it must be either the letter A, B or C).
    • Then it has non-terminal values in {}. Wavy brackets indicate that the value inside can be repeated 0 or more times.
      • If there are no repetitions then the Identifier can comprise of just a single letter.
      • If there are repetitions, it must follow the syntax within the brackets, noticeably <Letter> <Digit>, indicating that after the initial letter it must be followed by a letter then a digit.
      • If there are more than one repetition the syntax must be followed continually resulting in a pattern of <Letter> <Letter><Digit> <Letter><Digit>...
    • Thus a combination of Identifiers can be made with varying length with the repetition.
Some correct/valid definition of Identifier includes A, AB0, BA4, AA0A0 colourcoded the new repetitions of {}.

With these valid definition of Identifier, they can be used in the assignment statement of LET <Identifier> = <Identifier>, For example;
  • LET A = C
  • LET AB0 = AA0A0
  • LET BA4 = C
I used page 23 of the Course Specifics for the example above.

Please let me know if you still don't get it or if my explanation went on a tangent!
just adding this

Screen Shot 2023-09-28 at 8.55.23 am.png

from sam davis (summary)
 

SadCeliac

done hsc yay
Joined
Sep 23, 2021
Messages
2,490
Location
Sydney <3
Gender
Male
HSC
2023
I drew the railroad for the example above.
Remember that railroad diagrams uses lines to indicate the flow of syntax and repetition (the {0 or more repetitions} or [optional part]).

If you need any more clarifications or help let me know!
perfecttttt nice
do you always colour code or is this just for the sake of demonstration? just curious
 

SASH_06_X

Well-Known Member
Joined
Jun 5, 2023
Messages
441
Location
on my couch
Gender
Female
HSC
2023
I drew the railroad for the example above.
Remember that railroad diagrams uses lines to indicate the flow of syntax and repetition (the {0 or more repetitions} or [optional part]).

If you need any more clarifications or help let me know!
Right, thanks, that clarified it for me! Tysm
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top