Editing
Formal Languages
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Modeling 'The Simple Grammar' (A script that generates valid 'Sentences'):''' <syntaxhighlight lang="python"> import random # Formal Grammar: S -> Subject Verb grammar = { "Subject": ["Code", "Logic", "Data"], "Verb": ["Compiles", "Processes", "Crashes"] } def generate_formal_sentence(): """ Shows how 'Rules' generate 'Languages'. """ subj = random.choice(grammar["Subject"]) verb = random.choice(grammar["Verb"]) return f"{subj} {verb}" # Generating the 'Language' of this grammar print(f"Sentence 1: {generate_formal_sentence()}") print(f"Sentence 2: {generate_formal_sentence()}") </syntaxhighlight> ; Language Landmarks : '''Backus-Naur Form (BNF)''' β The "Standard Notation" used to "Write down" the rules of a programming language. It is the "Map" that all compiler-builders use. : '''HTML and XML''' β "Markup Languages" that are "Context-Free." They rely on "Balanced Tags," which is why you can't parse HTML with simple "Regular Expressions" (it's too complex for an FSM). : '''Natural Language Processing (NLP)''' β The attempt to treat "English" as a "Formal Language" so AIs can understand it. (This was the original goal of Chomsky, but English proved to be "Too Context-Sensitive" for simple math). : '''The 'Ambiguous' Grammar''' β A "Bug" in a language where "One sentence" can have "Two Different Syntax Trees" (e.g., '1 + 2 * 3'βdoes it mean 7 or 9?). Formal languages must be "Unambiguous" to work in a computer. </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information