Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSL Implement #5

Open
13 of 18 tasks
rainintime7 opened this issue Aug 15, 2024 · 0 comments
Open
13 of 18 tasks

DSL Implement #5

rainintime7 opened this issue Aug 15, 2024 · 0 comments

Comments

@rainintime7
Copy link
Collaborator

rainintime7 commented Aug 15, 2024

TO-DO list

  • complete nearley grammar
    • add structure and attribute grammar
    • add graph/matrix
  • update mermaid (unify attribute to adapt nearley)
  • update mermaid (add attri-id: page-component-unit to adapt GUI)
  • complete compiler in app
    • compiler for mermaid code
    • compiler for component/page table
  • update react state table to enable GUI
    • page table
    • component table
  • discuss user mode
    • update policy
    • lock policy
  • adjust renderer style
    • adjust size
    • update tree sibling distance with multiple layers
    • add the gap between tree node

DSL example
all 6 types of components' (array/matrix/tree/graph/linkedlist/stack) attributes are:

  array matrix linkedlist stack tree graph text nearley
attribute value,color,arrow value,color id,value,color,arrow value,color,arrow id,value,color node:[id,value,color,arrow,hidden] edge:[value,color]   id,value,color,arrow,hidden
example                

therefore to unify DSL and mermaid grammar, there should be 5 attribute in DSL (take the union):

  • id
  • value
  • color
  • arrow
  • hidden

so as former discussed, the DSL grammar would be like:

data:
	array arr = {
		structure: [[unit1],[unit1,unit2],[unit1,unit2,unit3], *] # unit_id, required
		value: [[1], [1,2], [1,2,3], [1,2,3] ] # value, optional
		color: [["blue"], [null,null],[], *] # color, optional
		arrow: [[],[null,"cur"],[null,null,"cur"]] # arrow, optional
		hidden: [[], [False, True], [False]] # hidden, optional
	}

draw:
	page p := [0,2] {
		show arr[p]
	}
	
	# value/color/arrow/hidden data doesn't need to aligh to structure data
	# it is correct on grammar but maybe incorrect in rendering
	# e.g in structure [[1],[1,2],[1,2,3]] if i want to only color unit "3"
	# all of this color data can work: 
	# [[],[],[null, null, blue]]
	# [[null,null,null,null,null], * ,[null, null, blue]]
	# [[null,null,null,null,null], [] ,[null, null, blue]]

a simplified example of DSL

data:
	array arr = {
		structure: [[unit1],[unit1,unit2],[unit1,unit2,unit3], *] # unit_id, required
	}
	linkedlist li = {
		structure: [[unit1],[unit1,unit2],[unit1,unit2,unit3], *] # unit_id, required
	}
	tree tr = {
		structure: [[node1],[node1,node2],[node1,node2,node3], *, *, *]
	}

draw:
	page p := [0,2] {
		show arr[p]
		show li[p-1]
	}
	page p := [3,3] {
		show li[3]
	}
	page i := [4,8] {
		show li[8-i]
		show tr[i]
	}

Do you think this grammar reasonable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant