Code Monkey home page Code Monkey logo

gamma's People

Contributors

kuniss avatar linkrope avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kuniss

gamma's Issues

Error positions of generated compilers are incorrect

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

Let compiler generation fail for unproductive nonterminals

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?

EOF not recognized on corner case specification

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 even if a compiler is created successfully

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.

Restructure Gamma include files required for the generated compiler

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.