Code Monkey home page Code Monkey logo

language-glsl's People

Contributors

conal avatar martinsstewart avatar maxsnew avatar noteed avatar osa1 avatar process-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

language-glsl's Issues

Missing parentheses in prettyBinary

The prettyBinary function in Language.GLSL.Pretty sometimes incorrectly omits parentheses.
For instance, (/) is left-associative, so "a / b / c" parses as "(a / b) / c", i.e.,

Div (Div (Variable "a") (Variable "b")) (Variable "c")

and "a / (b / c)" parses as

Div (Variable "a") (Div (Variable "b") (Variable "c"))

However, pretty-printing this last expression yields "a / b / c", which is incorrect.

The problematic code:

prettyBinary :: Pretty a =>
  PrettyLevel -> Rational -> Rational -> String -> a -> a -> Doc
prettyBinary l p op o e1 e2 = prettyParen (p > op) $
  pPrintPrec l op e1 <+> text o <+> pPrintPrec l op e2

To fix this bug, tweak the precedence context when pretty-printing the argument expressions, depending on the operator's associative:

  • Left-associative: tighten precedence on the right.
  • Right-associative: tighten precedence on the left.
  • Non-associative: tighten precedence on both sides.
type Assoc = (Rational -> Rational, Rational -> Rational)

assocLeft, assocRight, assocNone :: Assoc
assocLeft  = (id,bump)
assocRight = (bump,id)
assocNone  = (bump,bump)

bump :: Rational -> Rational
bump = (+ 0.5)

prettyBinary :: Pretty a =>
  PrettyLevel -> Rational -> Rational -> Assoc -> String -> a -> a -> Doc
prettyBinary l p op (lf,rf) o e1 e2 = prettyParen (p > op) $
  pPrintPrec l (lf op) e1 <+> text o <+> pPrintPrec l (rf op) e2

I submitted a pull request.

Running tests

Hello, I would like to try resolving this issue #4 (or at least enough to support #extension).

I'm stuck trying to build and run the tests for this repo though. When I run cabal test I get this error

PS C:\Users\Martin\Desktop\language-glsl> cabal test
Resolving dependencies...
Warning: solver failed to find a solution:
[__0] trying: language-glsl-0.3.0 (user goal)
line flag, or user target requires opposite flag selection)
[__1] trying: language-glsl:*test
[__2] unknown package: test-framework-hunit (dependency of language-glsl
*test)
[__1] fail (backjumping, conflict set: language-glsl, test-framework-hunit,
language-glsl:test)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: language-glsl, language-glsl:test,
test-framework-hunit
Trying configure anyway.
Configuring language-glsl-0.3.0...
cabal.exe: Encountered missing dependencies:
HUnit -any,
test-framework -any,
test-framework-hunit -any

(I get the same error for cabal configure and cabal build)

I'm new to haskell so maybe I'm missing something obvious.

GHC version: 8.4.3
cabal-install version 2.2.0.0

Build failure with GHC 7.10

Unpacking to language-glsl-0.1.1/
Resolving dependencies...
Configuring language-glsl-0.1.1...
Building language-glsl-0.1.1...
Preprocessing library language-glsl-0.1.1...
[1 of 4] Compiling Language.GLSL.Syntax ( Language/GLSL/Syntax.hs, dist/build/Language/GLSL/Syntax.o )
[2 of 4] Compiling Language.GLSL.Parser ( Language/GLSL/Parser.hs, dist/build/Language/GLSL/Parser.o )

Language/GLSL/Parser.hs:202:3: Warning: Defined but not used: ‘m’

Language/GLSL/Parser.hs:209:3: Warning: Defined but not used: ‘m’

Language/GLSL/Parser.hs:219:3: Warning: Defined but not used: ‘m’

Language/GLSL/Parser.hs:226:3: Warning: Defined but not used: ‘m’

Language/GLSL/Parser.hs:236:3: Warning: Defined but not used: ‘m’

Language/GLSL/Parser.hs:244:3: Warning: Defined but not used: ‘m’
[3 of 4] Compiling Language.GLSL.Pretty ( Language/GLSL/Pretty.hs, dist/build/Language/GLSL/Pretty.o )
[4 of 4] Compiling Language.GLSL    ( Language/GLSL.hs, dist/build/Language/GLSL.o )
In-place registering language-glsl-0.1.1...
Preprocessing executable 'glsl-pprint' for language-glsl-0.1.1...

bin/glsl-pprint.hs:4:8:
    Ambiguous module name ‘Text.PrettyPrint.HughesPJClass’:
      it was found in multiple packages:
      pretty-1.1.2.0@prett_7jIfj8VCGFf1WS0tIQ1XSZ prettyclass-1.0.0.0@prett_2FbqlbOn8rU3vmeTF7SGKM

Status of project

What's the status of this project? Is it/will it continue to be maintained?

Parser for array size expressions in block declarations seems to reject valid syntax

The Language.GLSL.Parser.parse function rejects the following code:

'''
layout (std140) uniform PatternBlock
{ float pattern[100];
};
void main ()
{ gl_FragColor = vec4 (1.0, 1.0, 0.0, 1.0);
}
'''

with the error:

'''
Left "GLSL" (line 2, column 17):
unexpected "1"
expecting "/", space or "]"
'''

From reading a bit in the specification (https://www.opengl.org/registry/doc/GLSLangSpec.1.50.11.pdf), I'm fairly sure that it should accept this syntax.

More precisely, it seems that the 'conditionalExpression' parser does not accept '100', which I believe it should (in spite of the name!), see *.

Looking at the implementation of 'conditionalExpression', it seems quite clear to me that Parsec's 'buildExpressionParser' function may not be the right fit, but I have not looked into why it fails yet.

I intend to investigate this a bit more in-depth shortly.
I'll send you a pull request if I figure out a valid fix.
Just thought I'd let you know in case I never get around to it.

*Note that it is not immediately obvious from the grammar in the spec that '100' should be accepted.
Here are the rewrites to get to '100' starting from conditional_expression:
conditional_expression, logical_or_expression, logical_xor_expression, logical_and_expression, inclusive_or_expression, exclusive_or_expression, and_expression, equality_expression, relational_expression, shift_expression, additive_expression, multiplicative_expression, unary_expression, postfix_expression, primary_expression, which includes INTCONSTANT.

Inferring array types

While using WebGL in Elm, I discovered the GLSL parser doesn't seem to infer types of arrays correctly.
For instance: uniform int array[32]; is inferred as having just the type Int.
I'm not sure about Haskell, but in Elm I expect this type to be inferred as Array Int.
Is this simply not supported, or is it a bug?

How usable is this project?

I have a few questions about using this library:

What versions of GLSL does it support?
Are there any critical portions of GLSL unsupported at this point?
Do you have any tutorials or rough guidelines for using the project?

Thanks!

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.