Skip to content

Commit

Permalink
rewrite grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
skanaar committed Jan 15, 2023
1 parent 26403aa commit 5389dd4
Show file tree
Hide file tree
Showing 28 changed files with 3,824 additions and 1,368 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ nomnoml.sublime-project
nomnoml.sublime-workspace
dist/nomnoml.compiled.js
dist/nomnoml-core-parser.js
dist/core-parser.js
dist/webapp.js
deploy.sh

Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nomnoml.css
webapp/
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 100
}
10 changes: 0 additions & 10 deletions build/build-parser.js

This file was deleted.

3,294 changes: 2,529 additions & 765 deletions dist/nomnoml.js

Large diffs are not rendered by default.

55 changes: 54 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
],
"types": "index.d.ts",
"dependencies": {
"graphre": "^0.1.3"
"graphre": "^0.1.3",
"peggy": "^2.0.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.1",
Expand All @@ -45,7 +46,7 @@
"prepare": "npm run webapp",
"build": "npm run lib && npm run webapp && npm run test",
"webapp": "rollup -c webapp/rollup.config.js",
"lib": "node build/build-parser.js && rollup -c src/rollup.config.js && npm test",
"lib": "peggy -o dist/core-parser.js src/grammar.pegjs && rollup -c src/rollup.config.js && npm test",
"test": "node test/index.js && npm run test_cli",
"test_cli": "rm -f test/output.svg && node dist/nomnoml-cli.js test/import-test.nomnoml test/output.svg"
},
Expand Down
37 changes: 3 additions & 34 deletions src/domain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Ranker } from 'graphre/decl/types'
import { Graphics } from './Graphics'
import { LayoutedNode } from './layouter'

export interface Config {
padding: number
Expand Down Expand Up @@ -33,11 +34,11 @@ export interface Measurer {
}

export interface Visualizer {
(node: Classifier, x: number, y: number, config: Config, g: Graphics): void
(node: LayoutedNode, x: number, y: number, config: Config, g: Graphics): void
}

export interface NodeLayouter {
(config: Config, node: Classifier): void
(config: Config, node: LayoutedNode): void
}

export type Visual =
Expand Down Expand Up @@ -80,42 +81,10 @@ export interface Style {
direction: 'TB' | 'LR' | undefined
}

export class Compartment {
x: number
y: number
width: number
height: number
offset: { x: number; y: number }
constructor(public lines: string[], public nodes: Classifier[], public relations: Relation[]) {}
}

export interface RelationLabel {
x?: number
y?: number
width?: number
height?: number
text: string
}

export class Relation {
id: number
path?: { x: number; y: number }[]
start: string
end: string
startLabel: RelationLabel
endLabel: RelationLabel
assoc: string
}

export class Classifier {
x: number
y: number
width: number
height: number
layoutWidth: number
layoutHeight: number
dividers: { x: number; y: number }[][]
constructor(public type: string, public name: string, public compartments: Compartment[]) {
this.dividers = []
}
}
Loading

0 comments on commit 5389dd4

Please sign in to comment.