prettier-plugin-glsl
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -236,2 +236,6 @@ import { IToken } from "chevrotain"; | ||
} | ||
export interface TypeQualifierDeclaration extends BaseNode { | ||
kind: "typeQualifierDeclaration"; | ||
typeQualifier: TypeQualifier; | ||
} | ||
export interface StructDeclaration extends BaseNode { | ||
@@ -273,3 +277,3 @@ kind: "structDeclaration"; | ||
export declare type PpNode = PpDefine | PpDir | PpExtension | PpCall | PpPragma; | ||
export declare type Declaration = FunctionDefinition | FunctionPrototype | InitDeclaratorListDeclaration | PrecisionDeclaration | InvariantDeclaration | UniformBlock | PpNode; | ||
export declare type Declaration = FunctionDefinition | FunctionPrototype | InitDeclaratorListDeclaration | PrecisionDeclaration | InvariantDeclaration | TypeQualifierDeclaration | UniformBlock | PpNode; | ||
export declare type JumpStatement = ReturnStatement | ContinueStatement | BreakStatement | DiscardStatement; | ||
@@ -276,0 +280,0 @@ export declare type IterationStatement = DoWhileStatement | ForStatement | WhileStatement; |
import { EmbeddedActionsParser, IRecognitionException, IRuleConfig, IToken, TokenType } from "chevrotain"; | ||
import { ArraySpecifier, CaseBlock, CaseLabel, CompoundStatement, Declaration, Expression, ExpressionStatement, FullySpecifiedType, FunctionCall, InitDeclaratorListDeclaration, IterationStatement, JumpStatement, LayoutQualifier, Node, ParameterDeclaration, PpCall, PpDefine, PpDir, PpExtension, PpNode, PpPragma, SelectionStatement, Statement, StorageQualifier, StructDeclaration, StructSpecifier, SwitchStatement, Token, TranslationUnit, TypeQualifier, TypeSpecifier, UniformBlock } from "./nodes"; | ||
import { ArraySpecifier, CaseBlock, CaseLabel, CompoundStatement, Declaration, Expression, ExpressionStatement, FullySpecifiedType, FunctionCall, InitDeclaratorListDeclaration, IterationStatement, JumpStatement, LayoutQualifier, Node, ParameterDeclaration, PpCall, PpDefine, PpDir, PpExtension, PpNode, PpPragma, SelectionStatement, Statement, StorageQualifier, StructDeclaration, StructSpecifier, SwitchStatement, Token, TranslationUnit, TypeQualifier, TypeQualifierDeclaration, TypeSpecifier, UniformBlock } from "./nodes"; | ||
declare class GLSLParser extends EmbeddedActionsParser { | ||
@@ -55,2 +55,3 @@ multiplicativeExpression: () => Expression; | ||
protected uniformBlockHeader: import("chevrotain").ParserMethod<[], void>; | ||
typeQualifierDeclaration: () => TypeQualifierDeclaration; | ||
externalDeclaration: (uniformBlock?: boolean, function_?: boolean) => Declaration; | ||
@@ -57,0 +58,0 @@ ppDefine: () => PpDefine; |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Prettier (https://prettier.io) plugin for GLSL (OpenGL Shading Language).", | ||
@@ -15,0 +15,0 @@ "exports": "./lib/prettier-plugin.cjs.js", |
@@ -319,2 +319,7 @@ import { IToken } from "chevrotain" | ||
export interface TypeQualifierDeclaration extends BaseNode { | ||
kind: "typeQualifierDeclaration" | ||
typeQualifier: TypeQualifier | ||
} | ||
export interface StructDeclaration extends BaseNode { | ||
@@ -369,2 +374,3 @@ kind: "structDeclaration" | ||
| InvariantDeclaration | ||
| TypeQualifierDeclaration | ||
| UniformBlock | ||
@@ -371,0 +377,0 @@ | PpNode |
@@ -52,2 +52,3 @@ /* eslint-disable @typescript-eslint/member-ordering */ | ||
TypeQualifier, | ||
TypeQualifierDeclaration, | ||
TypeSpecifier, | ||
@@ -614,2 +615,3 @@ UnaryExpression, | ||
}) | ||
this.CONSUME(TOKEN.RIGHT_PAREN) | ||
return { kind: "layoutQualifier", layoutQualifierIds } | ||
@@ -643,3 +645,12 @@ }) | ||
]) | ||
return { kind: "storageQualifier", CONST, CENTROID, IN, OUT, VARYING, ATTRIBUTE, UNIFORM } | ||
return { | ||
kind: "storageQualifier", | ||
CONST, | ||
CENTROID, | ||
IN, | ||
OUT, | ||
VARYING, | ||
ATTRIBUTE, | ||
UNIFORM, | ||
} | ||
}, | ||
@@ -1278,2 +1289,12 @@ ) | ||
}) | ||
public typeQualifierDeclaration = this.RR( | ||
"typeQualifierDeclaration", | ||
(): TypeQualifierDeclaration => { | ||
const typeQualifier = this.SUBRULE(this.typeQualifier) | ||
this.CONSUME(TOKEN.SEMICOLON) | ||
return { kind: "typeQualifierDeclaration", typeQualifier } | ||
}, | ||
) | ||
public externalDeclaration = this.RR( | ||
@@ -1285,2 +1306,7 @@ "externalDeclaration", | ||
{ ALT: () => this.SUBRULE(this.ppDirective) }, | ||
// type qualifier declaration | ||
{ | ||
GATE: this.BACKTRACK(this.typeQualifierDeclaration), | ||
ALT: () => this.SUBRULE(this.typeQualifierDeclaration), | ||
}, | ||
// uniform/interface block | ||
@@ -1287,0 +1313,0 @@ { |
@@ -521,3 +521,3 @@ // noinspection JSUnusedGlobalSymbols | ||
if (n.typeQualifier) { | ||
parts.push(p<typeof n>("typeQualifier")) | ||
parts.push(p<typeof n>("typeQualifier"), " ") | ||
} | ||
@@ -541,9 +541,9 @@ parts.push(p<typeof n>("typeSpecifier")) | ||
if (n.invariantQualifier) { | ||
parts.push("invariant ") | ||
parts.push("invariant") | ||
} | ||
if (n.interpolationQualifier) { | ||
parts.push(n.interpolationQualifier.image, " ") | ||
parts.push(n.interpolationQualifier.image) | ||
} | ||
if (n.layoutQualifier) { | ||
parts.push(p<typeof n>("layoutQualifier"), " ") | ||
parts.push(p<typeof n>("layoutQualifier")) | ||
} | ||
@@ -553,3 +553,3 @@ if (n.storageQualifier) { | ||
} | ||
return parts | ||
return join(" ", parts) | ||
} | ||
@@ -559,3 +559,3 @@ case "storageQualifier": { | ||
if (n.CONST) { | ||
parts.push("const ") | ||
parts.push("const") | ||
} | ||
@@ -570,20 +570,20 @@ // SPEC: "A variable may be qualified as flat centroid, which will | ||
) { | ||
parts.push("centroid ") | ||
parts.push("centroid") | ||
} | ||
if (n.IN) { | ||
parts.push("in ") | ||
parts.push("in") | ||
} | ||
if (n.OUT) { | ||
parts.push("out ") | ||
parts.push("out") | ||
} | ||
if (n.VARYING) { | ||
parts.push("varying ") | ||
parts.push("varying") | ||
} | ||
if (n.ATTRIBUTE) { | ||
parts.push("attribute ") | ||
parts.push("attribute") | ||
} | ||
if (n.UNIFORM) { | ||
parts.push("uniform ") | ||
parts.push("uniform") | ||
} | ||
return parts | ||
return join(" ", parts) | ||
} | ||
@@ -1096,2 +1096,30 @@ case "functionPrototype": | ||
} | ||
case "layoutQualifier": | ||
return [ | ||
"layout(", | ||
join( | ||
", ", | ||
n.layoutQualifierIds.map((lqi): Doc => { | ||
return lqi.init === undefined | ||
? lqi.IDENTIFIER.image | ||
: [lqi.IDENTIFIER.image, " = ", lqi.init.image] | ||
}), | ||
), | ||
")", | ||
] | ||
case "uniformBlock": | ||
return [ | ||
p<typeof n>("typeQualifier"), | ||
" ", | ||
n.blockName.image, | ||
" {", | ||
indent([ | ||
hardline, | ||
join(hardline, path.map(print, "declarations")), | ||
]), | ||
hardline, | ||
"};", | ||
] | ||
case "typeQualifierDeclaration": | ||
return [p<typeof n>("typeQualifier"), ";"] | ||
default: | ||
@@ -1098,0 +1126,0 @@ throw new Error( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
539802
11854