linkrope / gamma Goto Github PK
View Code? Open in Web Editor NEWExtended Affix Grammar Compiler Generator
License: Boost Software License 1.0
Extended Affix Grammar Compiler Generator
License: Boost Software License 1.0
Grammar: https://github.com/linkrope/gamma/blob/master/example/decl-appl.eag
Test source test.declappl (preserve empty lines!):
DECL aa
DECL aa
APPL ab
APPL ba
Will result in the following wrong error positions:
>~/git/gamma/build$ .//DeclAppl ../test/test.declappl
info: DeclAppl compiler (generated with epsilon)
error: predicate 'NotAlreadyDeclared' failed
../test/test.declappl:4:1 APPL ab
^
error: predicate 'Declared' failed
../test/test.declappl:5:1 APPL ba
^
error: predicate 'Declared' failed
../test/test.declappl:7:1
^
info: errors detected: 3
If nonterminals are unproductive the compiler generator does not fail but issues a warning only.
However, the subsequently running D compiler almost fail due to a missing method.
It would be appreciated if the compiler generator already fails for unproductive terminals and only succeeds if it is forced to do so (with command line argument "--force").
Example for reproduction:
Code = Code Code "ADD" | number "ENTER".
Expr <+ Code2>:
Term <Code1> ExprTail<Code1,Code2>.
ExprTail<- Code1, + Code3>:
"+" Term<Code2> ExprTail<Code1 Code2 "ADD", Code3>.
//ExprTail<- Code, + Code>: .
Term <+ number "ENTER": Code>:
number <number>.
number = "0" | "1".
number:
<+ "0": number> "0"
| <+ "1": number> "1".
The example results with epsilon in the following output:
denis@modula:~/tmp/epsilon$ ./epsilon expr-bnf.eag
info: Epsilon 1.02 JoDe/SteWe 22.11.96
info: SOAG-Evaluatorgenerator 1.06 dk 14.03.98
info: Analysing Expr
warn: 2 warnings
info: OK
warn: Analyser warnings on Expr's hyper-nonterminals:
warn: Expr unproductive
warn: ExprTail unproductive
Predicates in Expr: none.
ELL(1) testing Expr ok
SLEAG testing Expr ok
info: ScanGen writing Expr
info: compile ExprScan.d
ELL(1) writing Expr +rc +ct info: compile Expr.d
dmd Expr.d ExprScan.d -g include/runtime.d src/epsilon/io.d src/io.d src/log.d src/epsilon/soag/listacks.d
Expr.d(627): Error: undefined identifier P0, did you mean function P1?
Minimal erroneous EAG specification:
NoEOF<+ 'Done': Done>: 'x'.
Done = 'Done'.
The only recognized sentence should be a lonely 'x':
~/git/gamma/build$ echo x | ./NoEOF
info: NoEOF compiler (generated with epsilon)
Done
But it also compile successfully on input 'xx':
~/git/gamma/build$ echo xx | ./NoEOF
info: NoEOF compiler (generated with epsilon)
Done
In fact, it compiles on any arbitrary input after the first 'x':
~/git/gamma/build$ echo xsakdjf7 | ./NoEOF
info: NoEOF compiler (generated with epsilon)
Done
The compiler generator reports errors for LEAG and SingleSweep evaluator generation even if the SOAG evaluator generator can be created and, in fact, will be created.
A good example is example/count2.eag. It is neither a LEAG grammar nor an Singe Sweep grammar, but a SOAG evaluator can be generated and also will be, in fact:
denis@modula:~/git/gamma$ ./gamma example/count2.eag
info: Epsilon 1.02 JoDe/SteWe 22.11.96
info: SOAG-Evaluatorgenerator 1.06 dk 14.03.98
info: Analysing S
info: S grammar is valid
info: predicates in S: 1
info: ELL(1) testing S
info: S grammar is ELL(1)
info: SLAG testing S
error: not left-defining
example/count2.eag:6:7 A<N, N, Z>.
^
info: S grammar is no LAG
info: single-sweep testing S
error: alternative is not single sweep
example/count2.eag:5:10 S <+Z: Z>:
^
info: LexGen writing S
info: predicates in S: 1
info: grammar is SOAG
info: SOAG writing S
info: optimize
info: +rc +ct
info: ELL(1) writing parser of S
info: -rc -ct
info: dmd S.d SEval.d SLex.d -g include/runtime.d src/io.d src/log.d src/epsilon/soag/listacks.d
denis@modula:~/git/gamma$
This causes problems upstream in the EAG grammar extension as reported under kuniss/epsilon-ide-extensions#5.
A solution could be to report these issues not as errors but as warnings or infos as long as the particular evaluator class has not been explicitly requested via command line option by the user.
@linkrope, please create a first page on the project's wiki via GitHub GUI to get the wiki git repo created.
I may then contribute and you may merge my PRs as described here: https://gist.github.com/larrybotha/10650410
Currently the implicitly called dmd D compiler fail due to missing gamma includes:
dmd S.d SLex.d -g include/runtime.d src/io.d src/log.d src/epsilon/soag/listacks.d
Error: module runtime is in file 'include/runtime.d' which cannot be read
import path[0] = /usr/include/dmd/phobos
import path[1] = /usr/include/dmd/druntime/import
Error: module io is in file 'src/io.d' which cannot be read
import path[0] = /usr/include/dmd/phobos
import path[1] = /usr/include/dmd/druntime/import
Error: module log is in file 'src/log.d' which cannot be read
import path[0] = /usr/include/dmd/phobos
import path[1] = /usr/include/dmd/druntime/import
Error: module listacks is in file 'src/epsilon/soag/listacks.d' which cannot be read
import path[0] = /usr/include/dmd/phobos
import path[1] = /usr/include/dmd/druntime/import
It would be nice, if the gamma gets an additional command line parameter for specifying D include paths.
Or, the gamma include files are included relative the directory where the generated source code has been created, such that the implicit call would be done as:
dmd S.d SLex.d -g ./runtime.d ./io.d ./log.d ./listacks.d
In that case the gamma vscode extension could copy the include files alongside the generated source code and the implicit compilation could work seamlessly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.