Skip to content
Snippets Groups Projects
Select Git revision
  • 6cbd64865367a0fda29b6ec75ae9b1c206b72a41
  • dev default protected
  • main protected
  • feature/better-placeholders
  • 0.3.0
  • 0.2.5
  • 0.2.4
  • 0.2.3
  • 0.2.1
  • 0.2
  • 0.1
11 results

RelAstBase.parser

Blame
  • RelAstBase.parser 2.92 KiB
    Program goal =
    	type_decls.t relations.r {: return new Program(t, r); :}
    	| STRING_LITERAL STAR {: return new Program(); :}
    	;
    
    List type_decls =
    	/* empty */ {: return new List(); :}
    	| type_decls.l type_decl.d {: return l.add(d); :}
    	;
    
    TypeDecl type_decl =
    	ID type_decl_super.s components_opt.c SCOL
    	{: return new TypeDecl(ID, false, s, c); :}
    	| ABSTRACT ID type_decl_super.s components_opt.c SCOL
    	{: return new TypeDecl(ID, true, s, c); :}
    	;
    
    Opt type_decl_super =
    	/* empty */ {: return new Opt(); :}
    	| COL s_type_use.u {: return new Opt(u); :}
    	;
    
    SimpleTypeUse s_type_use =
    	ID {: return new SimpleTypeUse(ID); :}
    	;
    
    TypeUse type_use =
    	s_type_use.u {: return u; :}
    	| parameterized_type_use.p {: return p; :}
    	;
    ParameterizedTypeUse parameterized_type_use =
    	ID LT type_use_list.l GT {: return new ParameterizedTypeUse(ID, l); :}
    	;
    List type_use_list =
    	type_use.u {: return new List().add(u); :}
    	| type_use_list.l COMMA type_use.u {: return l.add(u); :}
    	;
    
    List components_opt =
    	/* empty */ {: return new List(); :}
    	| ASSIGN components.l {: return l; :}
    	;
    
    List components =
    	{: return new List(); :}
    	| components.l component.c {: return l.add(c); :}
    	;
    
    Component component =
    	ID COL s_type_use.u {: return new NormalComponent(ID, u); :}
    	| s_type_use.u {: return new NormalComponent(u.getID(), u); :}
    	// List
    	| ID COL s_type_use.u STAR {: return new ListComponent(ID, u); :}
    	| s_type_use.u STAR {: return new ListComponent(u.getID(), u); :}
    	// Opt
    	| LBRACKET ID COL s_type_use.u RBRACKET {: return new OptComponent(ID, u); :}
    	| LBRACKET s_type_use.u RBRACKET {: return new OptComponent(u.getID(), u); :}
    	// NTA
    	| SLASH ID COL s_type_use.u SLASH {: return new NTAComponent(ID, u); :}
    	| SLASH s_type_use.u SLASH {: return new NTAComponent(u.getID(), u); :}
    	// NTA Token (same as NTA)
    	| SLASH LT ID COL s_type_use.u GT SLASH {: return new NTAComponent(ID, u); :}
    	| SLASH LT s_type_use.u GT SLASH {: return new NTAComponent(u.getID(), u); :}
    	// Token
    	| LT ID COL type_use.u GT {: return new TokenComponent(ID, u); :}
    	| LT ID GT {: return new TokenComponent(ID, new SimpleTypeUse("String")); :}
    	;
    
    List relations =
    	/* empty */ {: return new List(); :}