basic-lang | BASIC : Microcomputer Edition | Interpreter library
kandi X-RAY | basic-lang Summary
kandi X-RAY | basic-lang Summary
The BASIC Programming Language: Microcomputer Edition.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of basic-lang
basic-lang Key Features
basic-lang Examples and Code Snippets
Community Discussions
Trending Discussions on basic-lang
QUESTION
This is a continuation to this question I asked earlier about a BNFC-grammar for propositional logic. I got it working with parentheses, as per the definition, but I would now like to extend the grammar to work without parentheses, with a catch however: no unnecessary outer parentheses allowed.
For example, the atomic sentence a
should be allowed, but (a)
should not be recognized. The sentence (a => b) & c
should also be allowed, but ((a => b) & c)
not, and so forth. The last example highlights the necessity for paretheses. The precedence levels are
- equivalence
<=>
and implication=>
, - conjuction
&
and disjunction|
- negation
-
and - atoms.
The higher the level, the earlier it will be parsed.
I got the grammar working with the unnecessary parentheses, by setting precedence levels to the different operators via recursion:
...ANSWER
Answered 2020-Apr-16 at 16:31You can do this by simply banning the parenthesised form from the toplevel. This requires writing the precedence hierarchy in a different fashion, in order to propagate the restriction through the hierarchy. In the following, the r
suffix indicates that the production is "restricted" to not be a parenthesised form.
I also fixed the reduce/reduce conflicts by eliminating one of the NOT
productions. See below.
(I hope I got the BNFC right. I wrote this in bison and tried to convert the syntax afterwards.)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install basic-lang
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page