🚧fastn 0.5
syntax
#1993
Arpita-Jaiswal
started this conversation in
General
Replies: 1 comment
-
I have also started writing grammar.bnf today, mostly inspired by your EBNF.md. I am trying to use the exact tokens I have in my tokens.rs file. Also, I am not trying to make the grammar a very valid grammar yet, maybe it will not work with the bnf grammar. The idea is I am trying to create readable grammar instead of "strictly correct" grammar. Maybe we can achieve both readable and correct grammar, but a correct grammar over readable grammar does not really give us anything, given that it is handwritten parser. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The
fastn 0.5
syntax builds onfastn 0.4
, introducing several key modifications to support complex operations. For those new tofastn 0.4
, you may want to review the discussion here to understand its foundational syntax and implementation.Lets start with simple grammar:
Understanding
fastn 0.5
p-script grammarGrammar with section body
A basic section definition can include an optional section type, name, caption, multiple headers, and an optional body:
Example
In this example:
<section-type>
: person<section-name>
: john<caption>
: John Doe<header-name>
: age<header-value>
: 10<header-name>
: gender<header-value>
: male<body>
:This is John Doe.
He is a software developer.
Grammar with subsections
Multiple subsections within a main section are enclosed within the section's start and end tags:
Example
In this example:
<section-name>
: team<caption>
: Development Team<header-name>
: location<header-value>
: San Francisco<header-name>
: industry<header-value>
: Technology<section-name>
: person<caption>
: Alice Smith<header-name>
: age<header-value>
: 28<header-name>
: role<header-value>
: Frontend Developer<section-name>
: person<caption>
: Bob Jones<header-name>
: age<header-value>
: 35<header-name>
: role<header-value>
: Backend DeveloperComment
Example
Module Doc Comment
Module comments at the beginning of the file provide meta-information. When placed directly above a section, they become section doc comments.
Example
Section Doc Comment
Each section can include doc comments to describe its purpose or behavior. It should appear right above the section.
Example
Symbol Definitions
*
: can appear zero or more times.?
: can appear zero or once.+
: must appear one or more times.[]
: encloses list of symbols and tokens<>
: tokenToken Definitions:
<section-type>
: Alphanumeric characters.<section-name>
: Alphanumeric characters.<header-type>
: Alphanumeric characters.<header-name>
: Alphanumeric characters.<body>
: Any characters.<subsection>
: Follows the same syntax as<section>
.<comment>
: Any characters.<caption> or <header-value>
: Can range from a string to complex f-script expressions, including function scripts and nested sections (explained further below).<caption> or <header-value>
These tokens allow complex types. They can include anything from simple strings to f-script function calls or even other nested sections, providing flexibility for various use cases.
1. Passing value in p-script:
You can pass any character
Example
2. Passing variable reference in p-script:
Example
3. Passing function in p-script:
Example
4. Passing value in f-script:
Single line value
Example
Multiline value
Example
Function value
Example
To understand better about string checkout Summarising Position On String
5. Passing sections:
Example
6. Passing
string-literals
:Example
Introducing new features in
fastn 0.5
Markup or
string-literal
🚧The string with UI is known as
string-literal
infastn
if
,for
andmatch
🚧More doc:
Beta Was this translation helpful? Give feedback.
All reactions