Saved location in tokens post parsing, fixed parsing just skipping stuff
(shoulda thought of that)
This commit is contained in:
@@ -2,29 +2,47 @@ Program {
|
||||
ast: Block(
|
||||
[
|
||||
Statement(
|
||||
Enum {
|
||||
name: Ident(
|
||||
"Foo",
|
||||
StatementBox {
|
||||
inner: Enum(
|
||||
Enum {
|
||||
name: Ident(
|
||||
"Foo",
|
||||
),
|
||||
fields: [],
|
||||
},
|
||||
),
|
||||
fields: [],
|
||||
loc: Loc {
|
||||
file: "parser/enumerations.mcl",
|
||||
line: 1,
|
||||
col: 5,
|
||||
},
|
||||
},
|
||||
),
|
||||
Statement(
|
||||
Enum {
|
||||
name: Ident(
|
||||
"Bar",
|
||||
StatementBox {
|
||||
inner: Enum(
|
||||
Enum {
|
||||
name: Ident(
|
||||
"Bar",
|
||||
),
|
||||
fields: [
|
||||
Ident(
|
||||
"A",
|
||||
),
|
||||
Ident(
|
||||
"B",
|
||||
),
|
||||
Ident(
|
||||
"C",
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
fields: [
|
||||
Ident(
|
||||
"A",
|
||||
),
|
||||
Ident(
|
||||
"B",
|
||||
),
|
||||
Ident(
|
||||
"C",
|
||||
),
|
||||
],
|
||||
loc: Loc {
|
||||
file: "parser/enumerations.mcl",
|
||||
line: 3,
|
||||
col: 5,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,53 +1,900 @@
|
||||
Program {
|
||||
ast: Block(
|
||||
[
|
||||
Expr(
|
||||
BinOp {
|
||||
typ: Eq,
|
||||
left: UnOp {
|
||||
typ: Star,
|
||||
right: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
],
|
||||
),
|
||||
Statement(
|
||||
StatementBox {
|
||||
inner: Let {
|
||||
name: Ident(
|
||||
"a",
|
||||
),
|
||||
typ: None,
|
||||
val: Some(
|
||||
ExprBox {
|
||||
inner: BinOp {
|
||||
typ: EqEq,
|
||||
left: ExprBox {
|
||||
inner: BinOp {
|
||||
typ: Star,
|
||||
left: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 1,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 1,
|
||||
col: 10,
|
||||
},
|
||||
},
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 3,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 1,
|
||||
col: 14,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 1,
|
||||
col: 12,
|
||||
},
|
||||
},
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 4,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 1,
|
||||
col: 18,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 1,
|
||||
col: 16,
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
right: BinOp {
|
||||
typ: EqEq,
|
||||
left: BinOp {
|
||||
typ: Star,
|
||||
left: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 1,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
right: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 3,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
right: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 4,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 1,
|
||||
col: 4,
|
||||
},
|
||||
},
|
||||
),
|
||||
Statement(
|
||||
StatementBox {
|
||||
inner: Let {
|
||||
name: Ident(
|
||||
"b",
|
||||
),
|
||||
typ: None,
|
||||
val: Some(
|
||||
ExprBox {
|
||||
inner: BinOp {
|
||||
typ: EqEq,
|
||||
left: ExprBox {
|
||||
inner: BinOp {
|
||||
typ: Div,
|
||||
left: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 3,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 2,
|
||||
col: 10,
|
||||
},
|
||||
},
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 4,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 2,
|
||||
col: 12,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 2,
|
||||
col: 11,
|
||||
},
|
||||
},
|
||||
right: ExprBox {
|
||||
inner: UnOp {
|
||||
typ: Star,
|
||||
right: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 2,
|
||||
col: 17,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 2,
|
||||
col: 16,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 2,
|
||||
col: 14,
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 2,
|
||||
col: 4,
|
||||
},
|
||||
},
|
||||
),
|
||||
Statement(
|
||||
StatementBox {
|
||||
inner: Let {
|
||||
name: Ident(
|
||||
"c",
|
||||
),
|
||||
typ: None,
|
||||
val: Some(
|
||||
ExprBox {
|
||||
inner: BinOp {
|
||||
typ: Div,
|
||||
left: ExprBox {
|
||||
inner: Group(
|
||||
ExprBox {
|
||||
inner: PtrFieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 11,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: FieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"b",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 13,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: PtrFieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"c",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 15,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"d",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 17,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 16,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 14,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 12,
|
||||
},
|
||||
},
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 10,
|
||||
},
|
||||
},
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 2,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 22,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 20,
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 3,
|
||||
col: 4,
|
||||
},
|
||||
},
|
||||
),
|
||||
Statement(
|
||||
StatementBox {
|
||||
inner: Let {
|
||||
name: Ident(
|
||||
"d",
|
||||
),
|
||||
typ: None,
|
||||
val: Some(
|
||||
ExprBox {
|
||||
inner: BinOp {
|
||||
typ: Div,
|
||||
left: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 2,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 4,
|
||||
col: 10,
|
||||
},
|
||||
},
|
||||
right: ExprBox {
|
||||
inner: PtrFieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 4,
|
||||
col: 14,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: FieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"b",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 4,
|
||||
col: 16,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: PtrFieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"c",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 4,
|
||||
col: 18,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"d",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 4,
|
||||
col: 20,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 4,
|
||||
col: 19,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 4,
|
||||
col: 17,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 4,
|
||||
col: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 4,
|
||||
col: 12,
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 4,
|
||||
col: 4,
|
||||
},
|
||||
},
|
||||
),
|
||||
Statement(
|
||||
StatementBox {
|
||||
inner: Let {
|
||||
name: Ident(
|
||||
"e",
|
||||
),
|
||||
typ: None,
|
||||
val: Some(
|
||||
ExprBox {
|
||||
inner: BinOp {
|
||||
typ: Div,
|
||||
left: ExprBox {
|
||||
inner: PtrFieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 5,
|
||||
col: 10,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: FieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"b",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 5,
|
||||
col: 12,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: PtrFieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"c",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 5,
|
||||
col: 14,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"d",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 5,
|
||||
col: 16,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 5,
|
||||
col: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 5,
|
||||
col: 13,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 5,
|
||||
col: 11,
|
||||
},
|
||||
},
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 2,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 5,
|
||||
col: 20,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 5,
|
||||
col: 18,
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 5,
|
||||
col: 4,
|
||||
},
|
||||
},
|
||||
),
|
||||
Statement(
|
||||
StatementBox {
|
||||
inner: Let {
|
||||
name: Ident(
|
||||
"f",
|
||||
),
|
||||
typ: None,
|
||||
val: Some(
|
||||
ExprBox {
|
||||
inner: BinOp {
|
||||
typ: Div,
|
||||
left: ExprBox {
|
||||
inner: FieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 6,
|
||||
col: 10,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: FieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"b",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 6,
|
||||
col: 12,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: FieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"c",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 6,
|
||||
col: 14,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"d",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 6,
|
||||
col: 16,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 6,
|
||||
col: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 6,
|
||||
col: 13,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 6,
|
||||
col: 11,
|
||||
},
|
||||
},
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 2,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 6,
|
||||
col: 20,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 6,
|
||||
col: 18,
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 6,
|
||||
col: 4,
|
||||
},
|
||||
},
|
||||
),
|
||||
Statement(
|
||||
StatementBox {
|
||||
inner: Let {
|
||||
name: Ident(
|
||||
"g",
|
||||
),
|
||||
typ: None,
|
||||
val: Some(
|
||||
ExprBox {
|
||||
inner: BinOp {
|
||||
typ: Star,
|
||||
left: ExprBox {
|
||||
inner: ArrayIndex {
|
||||
name: ExprBox {
|
||||
inner: FieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 10,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"b",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 12,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 11,
|
||||
},
|
||||
},
|
||||
index: ExprBox {
|
||||
inner: UnOp {
|
||||
typ: Star,
|
||||
right: ExprBox {
|
||||
inner: FieldAccess {
|
||||
left: Some(
|
||||
ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 15,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"c",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 17,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 16,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 14,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 13,
|
||||
},
|
||||
},
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 5,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 22,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 20,
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/expressions.mcl",
|
||||
line: 7,
|
||||
col: 4,
|
||||
},
|
||||
},
|
||||
),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
*a = 1 * 3 == 4;
|
||||
b.c = 3/4 == *a;
|
||||
c->d = (a->b.c->d) / 2;
|
||||
*d->e.f = 2 / a->b.c->d;
|
||||
e = a->b.c->d / 2;
|
||||
f = a.b.c.d / 2;
|
||||
g = a.b[*a.c] * 5;
|
||||
let a = 1 * 3 == 4;
|
||||
let b = 3/4 == *a;
|
||||
let c = (a->b.c->d) / 2;
|
||||
let d = 2 / a->b.c->d;
|
||||
let e = a->b.c->d / 2;
|
||||
let f = a.b.c.d / 2;
|
||||
let g = a.b[*a.c] * 5;
|
||||
|
||||
|
||||
@@ -2,187 +2,298 @@ Program {
|
||||
ast: Block(
|
||||
[
|
||||
Statement(
|
||||
Fn {
|
||||
struct_name: None,
|
||||
name: Ident(
|
||||
"main",
|
||||
),
|
||||
params: [
|
||||
(
|
||||
Ident(
|
||||
"argc",
|
||||
StatementBox {
|
||||
inner: Fn(
|
||||
Function {
|
||||
struct_name: None,
|
||||
name: Ident(
|
||||
"main",
|
||||
),
|
||||
Owned(
|
||||
Ident(
|
||||
"i32",
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
Ident(
|
||||
"argv",
|
||||
),
|
||||
Ref {
|
||||
inner: Array {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Str",
|
||||
),
|
||||
params: [
|
||||
(
|
||||
Ident(
|
||||
"argc",
|
||||
),
|
||||
},
|
||||
mutable: false,
|
||||
},
|
||||
),
|
||||
],
|
||||
ret_type: Some(
|
||||
Owned(
|
||||
Ident(
|
||||
"i32",
|
||||
),
|
||||
),
|
||||
),
|
||||
qual_const: false,
|
||||
qual_extern: None,
|
||||
body: Some(
|
||||
Block(
|
||||
[
|
||||
Expr(
|
||||
Return(
|
||||
Some(
|
||||
Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 0,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
TypeBox {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"i32",
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 1,
|
||||
col: 18,
|
||||
},
|
||||
},
|
||||
),
|
||||
(
|
||||
Ident(
|
||||
"argv",
|
||||
),
|
||||
TypeBox {
|
||||
inner: Ref {
|
||||
inner: Array {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Str",
|
||||
),
|
||||
),
|
||||
},
|
||||
mutable: false,
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 1,
|
||||
col: 27,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
ret_type: Some(
|
||||
TypeBox {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"i32",
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 1,
|
||||
col: 39,
|
||||
},
|
||||
},
|
||||
),
|
||||
qual_const: false,
|
||||
qual_extern: None,
|
||||
body: Some(
|
||||
Block(
|
||||
[
|
||||
Expr(
|
||||
ExprBox {
|
||||
inner: Return(
|
||||
Some(
|
||||
ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 0,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 2,
|
||||
col: 13,
|
||||
},
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 2,
|
||||
col: 11,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 1,
|
||||
col: 3,
|
||||
},
|
||||
},
|
||||
),
|
||||
Statement(
|
||||
Fn {
|
||||
struct_name: Some(
|
||||
Ident(
|
||||
"Baz",
|
||||
),
|
||||
),
|
||||
name: Ident(
|
||||
"main",
|
||||
),
|
||||
params: [
|
||||
(
|
||||
Ident(
|
||||
"self",
|
||||
),
|
||||
Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Baz",
|
||||
),
|
||||
),
|
||||
mutable: true,
|
||||
},
|
||||
),
|
||||
(
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Foo",
|
||||
),
|
||||
),
|
||||
mutable: false,
|
||||
},
|
||||
),
|
||||
(
|
||||
Ident(
|
||||
"b",
|
||||
),
|
||||
Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Bar",
|
||||
),
|
||||
),
|
||||
mutable: true,
|
||||
},
|
||||
),
|
||||
],
|
||||
ret_type: Some(
|
||||
Ref {
|
||||
inner: Owned(
|
||||
StatementBox {
|
||||
inner: Fn(
|
||||
Function {
|
||||
struct_name: Some(
|
||||
Ident(
|
||||
"Nya",
|
||||
"Baz",
|
||||
),
|
||||
),
|
||||
mutable: false,
|
||||
name: Ident(
|
||||
"main",
|
||||
),
|
||||
params: [
|
||||
(
|
||||
Ident(
|
||||
"self",
|
||||
),
|
||||
TypeBox {
|
||||
inner: Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Baz",
|
||||
),
|
||||
),
|
||||
mutable: true,
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 4,
|
||||
col: 20,
|
||||
},
|
||||
},
|
||||
),
|
||||
(
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
TypeBox {
|
||||
inner: Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Foo",
|
||||
),
|
||||
),
|
||||
mutable: false,
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 4,
|
||||
col: 33,
|
||||
},
|
||||
},
|
||||
),
|
||||
(
|
||||
Ident(
|
||||
"b",
|
||||
),
|
||||
TypeBox {
|
||||
inner: Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Bar",
|
||||
),
|
||||
),
|
||||
mutable: true,
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 4,
|
||||
col: 42,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
ret_type: Some(
|
||||
TypeBox {
|
||||
inner: Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Nya",
|
||||
),
|
||||
),
|
||||
mutable: false,
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 4,
|
||||
col: 54,
|
||||
},
|
||||
},
|
||||
),
|
||||
qual_const: false,
|
||||
qual_extern: None,
|
||||
body: None,
|
||||
},
|
||||
),
|
||||
qual_const: false,
|
||||
qual_extern: None,
|
||||
body: None,
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 4,
|
||||
col: 3,
|
||||
},
|
||||
},
|
||||
),
|
||||
Statement(
|
||||
Fn {
|
||||
struct_name: Some(
|
||||
Ident(
|
||||
"Baz",
|
||||
),
|
||||
),
|
||||
name: Ident(
|
||||
"main",
|
||||
),
|
||||
params: [
|
||||
(
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Foo",
|
||||
),
|
||||
),
|
||||
mutable: false,
|
||||
},
|
||||
),
|
||||
(
|
||||
Ident(
|
||||
"b",
|
||||
),
|
||||
Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Bar",
|
||||
),
|
||||
),
|
||||
mutable: true,
|
||||
},
|
||||
),
|
||||
],
|
||||
ret_type: Some(
|
||||
Ref {
|
||||
inner: Owned(
|
||||
StatementBox {
|
||||
inner: Fn(
|
||||
Function {
|
||||
struct_name: Some(
|
||||
Ident(
|
||||
"Nya",
|
||||
"Baz",
|
||||
),
|
||||
),
|
||||
mutable: false,
|
||||
name: Ident(
|
||||
"main",
|
||||
),
|
||||
params: [
|
||||
(
|
||||
Ident(
|
||||
"a",
|
||||
),
|
||||
TypeBox {
|
||||
inner: Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Foo",
|
||||
),
|
||||
),
|
||||
mutable: false,
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 5,
|
||||
col: 17,
|
||||
},
|
||||
},
|
||||
),
|
||||
(
|
||||
Ident(
|
||||
"b",
|
||||
),
|
||||
TypeBox {
|
||||
inner: Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Bar",
|
||||
),
|
||||
),
|
||||
mutable: true,
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 5,
|
||||
col: 26,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
ret_type: Some(
|
||||
TypeBox {
|
||||
inner: Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"Nya",
|
||||
),
|
||||
),
|
||||
mutable: false,
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 5,
|
||||
col: 38,
|
||||
},
|
||||
},
|
||||
),
|
||||
qual_const: false,
|
||||
qual_extern: None,
|
||||
body: None,
|
||||
},
|
||||
),
|
||||
qual_const: false,
|
||||
qual_extern: None,
|
||||
body: None,
|
||||
loc: Loc {
|
||||
file: "parser/functions.mcl",
|
||||
line: 5,
|
||||
col: 3,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -2,35 +2,63 @@ Program {
|
||||
ast: Block(
|
||||
[
|
||||
Expr(
|
||||
If(
|
||||
IfExpr {
|
||||
test: BinOp {
|
||||
typ: Gt,
|
||||
left: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"i",
|
||||
ExprBox {
|
||||
inner: If(
|
||||
IfExpr {
|
||||
test: ExprBox {
|
||||
inner: BinOp {
|
||||
typ: Gt,
|
||||
left: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"i",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
right: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 3,
|
||||
base: 10,
|
||||
signed: false,
|
||||
loc: Loc {
|
||||
file: "parser/if-statements.mcl",
|
||||
line: 2,
|
||||
col: 5,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 3,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/if-statements.mcl",
|
||||
line: 2,
|
||||
col: 9,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/if-statements.mcl",
|
||||
line: 2,
|
||||
col: 7,
|
||||
},
|
||||
},
|
||||
body: Block(
|
||||
[],
|
||||
),
|
||||
else_if: None,
|
||||
},
|
||||
body: Block(
|
||||
[],
|
||||
),
|
||||
else_if: None,
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/if-statements.mcl",
|
||||
line: 2,
|
||||
col: 3,
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -2,106 +2,204 @@ Program {
|
||||
ast: Block(
|
||||
[
|
||||
Expr(
|
||||
ForLoop {
|
||||
init: Statement(
|
||||
Let {
|
||||
name: Ident(
|
||||
"i",
|
||||
),
|
||||
typ: None,
|
||||
val: Some(
|
||||
Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 0,
|
||||
base: 10,
|
||||
signed: false,
|
||||
ExprBox {
|
||||
inner: ForLoop {
|
||||
init: Statement(
|
||||
StatementBox {
|
||||
inner: Let {
|
||||
name: Ident(
|
||||
"i",
|
||||
),
|
||||
typ: None,
|
||||
val: Some(
|
||||
ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 0,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 1,
|
||||
col: 14,
|
||||
},
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 1,
|
||||
col: 8,
|
||||
},
|
||||
},
|
||||
),
|
||||
test: ExprBox {
|
||||
inner: BinOp {
|
||||
typ: Lt,
|
||||
left: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"i",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 1,
|
||||
col: 17,
|
||||
},
|
||||
},
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 10,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 1,
|
||||
col: 22,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 1,
|
||||
col: 19,
|
||||
},
|
||||
},
|
||||
),
|
||||
test: BinOp {
|
||||
typ: Lt,
|
||||
left: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"i",
|
||||
on_loop: ExprBox {
|
||||
inner: BinOp {
|
||||
typ: AddEq,
|
||||
left: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"i",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
right: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 10,
|
||||
base: 10,
|
||||
signed: false,
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 1,
|
||||
col: 25,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 1,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 1,
|
||||
col: 29,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 1,
|
||||
col: 27,
|
||||
},
|
||||
},
|
||||
body: Block(
|
||||
[],
|
||||
),
|
||||
},
|
||||
on_loop: BinOp {
|
||||
typ: AddEq,
|
||||
left: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"i",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
right: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 1,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 1,
|
||||
col: 4,
|
||||
},
|
||||
body: Block(
|
||||
[],
|
||||
),
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
WhileLoop {
|
||||
test: BinOp {
|
||||
typ: Gt,
|
||||
left: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"i",
|
||||
ExprBox {
|
||||
inner: WhileLoop {
|
||||
test: ExprBox {
|
||||
inner: BinOp {
|
||||
typ: Gt,
|
||||
left: ExprBox {
|
||||
inner: Path(
|
||||
Path(
|
||||
[
|
||||
Ident(
|
||||
"i",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
right: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 3,
|
||||
base: 10,
|
||||
signed: false,
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 2,
|
||||
col: 8,
|
||||
},
|
||||
},
|
||||
),
|
||||
right: ExprBox {
|
||||
inner: Literal(
|
||||
Number(
|
||||
Number {
|
||||
val: 3,
|
||||
base: 10,
|
||||
signed: false,
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 2,
|
||||
col: 12,
|
||||
},
|
||||
},
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 2,
|
||||
col: 10,
|
||||
},
|
||||
},
|
||||
body: Block(
|
||||
[],
|
||||
),
|
||||
},
|
||||
body: Block(
|
||||
[],
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 2,
|
||||
col: 6,
|
||||
},
|
||||
},
|
||||
),
|
||||
Expr(
|
||||
InfLoop {
|
||||
body: Block(
|
||||
[],
|
||||
),
|
||||
ExprBox {
|
||||
inner: InfLoop {
|
||||
body: Block(
|
||||
[],
|
||||
),
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/loops.mcl",
|
||||
line: 3,
|
||||
col: 5,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -2,33 +2,58 @@ Program {
|
||||
ast: Block(
|
||||
[
|
||||
Statement(
|
||||
Struct {
|
||||
name: Ident(
|
||||
"foo_t",
|
||||
StatementBox {
|
||||
inner: Struct(
|
||||
Struct {
|
||||
name: Ident(
|
||||
"foo_t",
|
||||
),
|
||||
fields: [],
|
||||
},
|
||||
),
|
||||
fields: [],
|
||||
loc: Loc {
|
||||
file: "parser/structs.mcl",
|
||||
line: 2,
|
||||
col: 7,
|
||||
},
|
||||
},
|
||||
),
|
||||
Statement(
|
||||
Struct {
|
||||
name: Ident(
|
||||
"bar_t",
|
||||
),
|
||||
fields: [
|
||||
(
|
||||
Ident(
|
||||
"a",
|
||||
StatementBox {
|
||||
inner: Struct(
|
||||
Struct {
|
||||
name: Ident(
|
||||
"bar_t",
|
||||
),
|
||||
Ref {
|
||||
inner: Owned(
|
||||
fields: [
|
||||
(
|
||||
Ident(
|
||||
"bar_t",
|
||||
"a",
|
||||
),
|
||||
TypeBox {
|
||||
inner: Ref {
|
||||
inner: Owned(
|
||||
Ident(
|
||||
"bar_t",
|
||||
),
|
||||
),
|
||||
mutable: false,
|
||||
},
|
||||
loc: Loc {
|
||||
file: "parser/structs.mcl",
|
||||
line: 5,
|
||||
col: 9,
|
||||
},
|
||||
},
|
||||
),
|
||||
mutable: false,
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
},
|
||||
),
|
||||
loc: Loc {
|
||||
file: "parser/structs.mcl",
|
||||
line: 4,
|
||||
col: 7,
|
||||
},
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user