-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixed linting issues, refactoring some code along the way
affects: @postdfm/dfm2ast
- Loading branch information
1 parent
5aac96e
commit b158774
Showing
20 changed files
with
213 additions
and
154 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ASTType } from "./astType"; | ||
|
||
export class ASTNode { | ||
public astType: ASTType; | ||
constructor(astType: ASTType) { | ||
this.astType = astType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export enum ASTType { | ||
String = "string", | ||
HexString = "hexString", | ||
Integer = "integer", | ||
Double = "double", | ||
Boolean = "boolean", | ||
Qualified = "qualified", | ||
Item = "item", | ||
StringList = "stringList", | ||
QualifiedList = "qualifiedList", | ||
ItemList = "itemList", | ||
Property = "property", | ||
Object = "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { ASTNode } from "./astNode"; | ||
import { ASTType } from "./astType"; | ||
import { ObjectKind } from "./objectKind"; | ||
import { Property } from "./property"; | ||
|
||
export class FormObject extends ASTNode { | ||
public kind: ObjectKind; | ||
public name: string; | ||
public type: string; | ||
public order: number; | ||
public properties: Property[]; | ||
public children: FormObject[]; | ||
|
||
constructor( | ||
kind: ObjectKind, | ||
name: string, | ||
type: string, | ||
order: number, | ||
properties?: Property[], | ||
children?: FormObject[] | ||
) { | ||
super(ASTType.Object); | ||
this.kind = kind; | ||
this.name = name; | ||
this.type = type; | ||
|
||
if (order) { | ||
this.order = order; | ||
} | ||
|
||
if (properties) { | ||
this.properties = properties; | ||
} | ||
|
||
if (children) { | ||
this.children = children; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export { ASTType } from "./astType"; | ||
export { ASTNode } from "./astNode"; | ||
|
||
export { Value } from "./value/value"; | ||
export { StringValue } from "./value/stringValue"; | ||
export { HexStringValue } from "./value/hexStringValue"; | ||
export { IntegerValue } from "./value/integerValue"; | ||
export { DoubleValue } from "./value/doubleValue"; | ||
export { BooleanValue } from "./value/booleanValue"; | ||
export { QualifiedValue } from "./value/qualifiedValue"; | ||
|
||
export { Item } from "./item"; | ||
|
||
export { List } from "./list/list"; | ||
export { QualifiedList } from "./list/qualifiedList"; | ||
export { StringList } from "./list/stringList"; | ||
export { ItemList } from "./list/itemList"; | ||
|
||
export { Property } from "./property"; | ||
|
||
export { ObjectKind } from "./objectKind"; | ||
|
||
export { FormObject } from "./formObject"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ASTNode } from "./astNode"; | ||
import { ASTType } from "./astType"; | ||
import { Property } from "./property"; | ||
|
||
export class Item extends ASTNode { | ||
public properties: Property[]; | ||
|
||
constructor(properties: Property[]) { | ||
super(ASTType.Item); | ||
this.properties = properties; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ASTType } from "../astType"; | ||
import { Item } from "../item"; | ||
import { List } from "./list"; | ||
|
||
export class ItemList extends List<Item> { | ||
constructor(values: Item[]) { | ||
super(ASTType.ItemList, values); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ASTNode } from "../astNode"; | ||
import { ASTType } from "../astType"; | ||
|
||
export class List<T> extends ASTNode { | ||
public values: T[]; | ||
|
||
constructor(astType: ASTType, values: T[]) { | ||
super(astType); | ||
this.values = values; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ASTType } from "../astType"; | ||
import { QualifiedValue } from "../value/qualifiedValue"; | ||
import { List } from "./list"; | ||
|
||
export class QualifiedList extends List<QualifiedValue> { | ||
constructor(values: QualifiedValue[]) { | ||
super(ASTType.QualifiedList, values); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ASTType } from "../astType"; | ||
import { StringValue } from "../value/stringValue"; | ||
import { List } from "./list"; | ||
|
||
export class StringList extends List<StringValue> { | ||
constructor(values: StringValue[]) { | ||
super(ASTType.StringList, values); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum ObjectKind { | ||
Object = "object", | ||
Inline = "inline", | ||
Inherited = "inherited" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ASTNode } from "./astNode"; | ||
import { ASTType } from "./astType"; | ||
import { List } from "./list/list"; | ||
import { Value } from "./value/value"; | ||
|
||
export class Property extends ASTNode { | ||
public name: string; | ||
public value: Value<any> | List<any>; | ||
|
||
constructor(name: string, value: Value<any> | List<any>) { | ||
super(ASTType.Property); | ||
this.name = name; | ||
this.value = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ASTType } from "../astType"; | ||
import { Value } from "./value"; | ||
|
||
export class BooleanValue extends Value<boolean> { | ||
constructor(value: boolean) { | ||
super(ASTType.Boolean, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ASTType } from "../astType"; | ||
import { Value } from "./value"; | ||
|
||
export class DoubleValue extends Value<number> { | ||
constructor(value: number) { | ||
super(ASTType.Double, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ASTType } from "../astType"; | ||
import { Value } from "./value"; | ||
|
||
export class HexStringValue extends Value<string> { | ||
constructor(value: string) { | ||
super(ASTType.HexString, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ASTType } from "../astType"; | ||
import { Value } from "./value"; | ||
|
||
export class IntegerValue extends Value<number> { | ||
constructor(value: number) { | ||
super(ASTType.Integer, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ASTType } from "../astType"; | ||
import { Value } from "./value"; | ||
|
||
export class QualifiedValue extends Value<string> { | ||
constructor(value: string) { | ||
super(ASTType.Qualified, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ASTType } from "../astType"; | ||
import { Value } from "./value"; | ||
|
||
export class StringValue extends Value<string> { | ||
constructor(value: string) { | ||
super(ASTType.String, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ASTNode } from "../astNode"; | ||
import { ASTType } from "../astType"; | ||
|
||
export class Value<T> extends ASTNode { | ||
public value: T; | ||
constructor(astType: ASTType, value: T) { | ||
super(astType); | ||
this.value = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters