Skip to content

Commit

Permalink
Fixed conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagobapt committed Dec 4, 2024
1 parent 1c0f51e commit 3f38afb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 33 deletions.
2 changes: 2 additions & 0 deletions CheckLanguageWebsite/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ let parserWithMetadata = parser.configure({
Expression_Operator: t.arithmeticOperator,
Term_Operator: t.arithmeticOperator,
Comment: t.comment,
And: t.logicOperator,
Or: t.logicOperator,
"( )": t.paren,
"{ }": t.bracket,
"= ; ,": t.operator,
Expand Down
20 changes: 11 additions & 9 deletions CheckLanguageWebsite/src/CheckLang.terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ export const
If_Statement = 20,
Conditional = 21,
Logical_Operator = 22,
Statement_List = 25,
Else_Statement = 26,
While_Statement = 27,
For_Statement = 28,
Initialization = 29,
Function_Declaration = 30,
Parameter_Declaration = 31,
Types = 32,
Return_Statement = 33
And = 23,
Or = 24,
Statement_List = 27,
Else_Statement = 28,
While_Statement = 29,
For_Statement = 30,
Initialization = 31,
Function_Declaration = 32,
Parameter_Declaration = 33,
Types = 34,
Return_Statement = 35
16 changes: 8 additions & 8 deletions CheckLanguageWebsite/src/CheckLang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
import {LRParser} from "@lezer/lr"
export const parser = LRParser.deserialize({
version: 14,
states: ".dQYQPOOO!QQPO'#DXO!cQPO'#CmOOQO'#DX'#DXO!cQPO'#DXO!wQPO'#DWO#]QPO'#DVO#nQPO'#CpO#sQPO'#CwO#xQPO'#CxO#}QPO'#CyO$SQPO'#CzO!cQPO'#C}OOQO'#DU'#DUO$XQPO'#DUOOQO'#DO'#DOQYQPOOO!cQPO,59RO!cQPO,58zO$oQPO'#DXO$yQPO,59XO%RQPO,59sO!cQPO,59rO!cQPO,59qO%WQPO,59[O%WQPO,59cO%lQPO,59dO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!UO~OR!VO~O^sOY]X~OY!XO~OR!YO~O^sO_!]O~Of{X!P{X!Q{X~P$^Ob#TOczXfzXYzX!PzX!QzXRzX~Oc#UOfyXYyX!PyX!QyXRyX~Of!^O~O!P!_OY}X!Q}XR}X~O!Q!`OYeXReX~OY!aO~OY!bO~OUbO~OR!cO~Op!eO~O^sOY]a~Oh!jO~Oh!lO~OR!nO~OT!oO~OY!pO~Og!qO~PYO!R!sOTdyVdyWdyXdy[dy`dyudy|dy!Sdy!Tdy!Udy!Vdy!WdygdyYdy~OR!vO~O^!wOYoa~Og!zO~PYOg!|O~Op#OO~O^!wOYoi~OY#QO~OT#RO~Of#VO~O!P#XOY}XR}X~O!S|!R!T!U!V!WXT!U~",
goto: "'X!PPPPP!QPPPPPP!]P!xPPP!]PP!{#TPPP#^#j!{!{!{!{#mP!{#p#z$UPPP$[$h%e&SP&s&{[]O`!j!l!r!vR!Sj!TROQS[`abfghis!T!^!_!`!c!j!l!r!v#T#U#V#XRqa]]O`!j!l!r!vQ!PhQ!QiR!m!cQ!k!aQ!y!pQ!{!sR#S#QR!t!kR!f!UQ`OSo`!rR!r!jQtdQ!WpT![t!WQ!x!oR#P!xW_O`!j!rQ!u!lR!}!v[^O`!j!l!r!vQdQQeSQm[QpaQrbY|hi!_!`!cQ!ZsQ!d!TS!g!^#VR#W#XlUOQS[`abs!T!j!l!r!v#VSxg#U_{hi!^!_!`!c#XnTOQS[`abgs!T!j!l!r!v#VSwf#Tazhi!^!_!`!c#U#XU!Ohi!cR!i!`U}hi!cS!h!_#XR#Y!`",
nodeNames: "⚠ Comment Program ; Assignment Name = Number String Boolean ) Function_Call ( Parameter , ] [ Array Term_Operator Expression_Operator If_Statement Conditional Logical_Operator } { Statement_List Else_Statement While_Statement For_Statement Initialization Function_Declaration Parameter_Declaration Types Return_Statement",
states: "-zQYQPOOO!QQPO'#DZO!cQPO'#CmOOQO'#DZ'#DZO!cQPO'#DZO!wQPO'#DYO#cQPO'#DXO#zQPO'#CpO$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O`QO~ObfOR|Xc|X^|X_|XY|Xg|Xh|X~OcgOR{X^{X_{XY{Xg{Xh{X~O[hO~O[iO~O[jO~OTkO~OTlO~ORnO~O[aO^}X_}Xb}Xc}XY}XR}Xg}Xh}X~O^sO_uO~OYvO~OTyOVROWROXRO[SO`QO~OT!RO~OU!TO~O[!UO~OR!VO~O^sOY]X~OY!XO~OR!YO~O^sO_!]O~O[aOb}Xc}Xf}X~Ob#TOc|Xf|X~Oc#UOf{X~Of!^O~Og!_OY!PXh!PXR!PX~Oh!`OYeXReX~OY!aO~OY!bO~OUbO~OR!cO~Or!eO~O^sOY]a~Oj!jO~Oj!lO~OR!nO~OT!oO~OY!pO~Oi!qO~PYO!R!sOTdyVdyWdyXdy[dy`dywdy!Ody!Sdy!Tdy!Udy!Vdy!WdyidyYdy~OR!vO~O^!wOYqa~Oi!zO~PYOi!|O~Or#OO~O^!wOYqi~OY#QO~OT#RO~O!S!O!R!T!U!V!WXT!U~",
goto: "&|!RPPPP!SPPPPPP!_P!xPPP!_PP!{#TPPPPP#^#j!{!{!{!{#mP!{#p#z$UPPP$[$h%a%|P&k&s[]O`!j!l!r!vR!Sj!PROQS[`abfghis!T!^!_!`!c!j!l!r!v#T#URqa]]O`!j!l!r!vQ!PhQ!QiR!m!cQ!k!aQ!y!pQ!{!sR#S#QR!t!kR!f!UQ`OSo`!rR!r!jQtdQ!WpT![t!WQ!x!oR#P!xW_O`!j!rQ!u!lR!}!v[^O`!j!l!r!vQdQQeSQm[QpaQrbY|hi!_!`!cQ!ZsQ!d!TR!g!^lUOQS[`abs!T!^!j!l!r!vSxg#UZ{hi!_!`!cnTOQS[`abgs!T!^!j!l!r!vSwf#T]zhi!_!`!c#UU!Ohi!cR!i!`W}hi!`!cR!h!_",
nodeNames: "⚠ Comment Program ; Assignment Name = Number String Boolean ) Function_Call ( Parameter , ] [ Array Term_Operator Expression_Operator If_Statement Conditional Logical_Operator And Or } { Statement_List Else_Statement While_Statement For_Statement Initialization Function_Declaration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
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
| <array>
| <function>
| "(" <expression> ")"
<conditional> ::= <bool_term> { ("or") <bool_term> }
<bool_term> ::= <bool_factor> { ("and") <bool_factor> }
<conditional> ::= <bool_term> ( "||" <bool_term> )
<bool_term> ::= <bool_factor> ( "&&" <bool_factor> )
<bool_factor> ::= <expression> <relational_operator> <expression>
<relational_operator> ::= "==" | "!=" | "<" | "<=" | ">" | ">=" | "||" | "&&"
<number> ::= [0-9]+
Expand Down
6 changes: 4 additions & 2 deletions src/CheckLang.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ factor { Number | Name | String | Boolean | Function_Call | Array | "(" expressi

Array { "[" expression ("," expression)* "]" }

Conditional { bool_term ( "or" bool_term )? }
Conditional { bool_term ( Or bool_term )? }

bool_term { bool_factor ( "and" bool_factor )? }
bool_term { bool_factor ( And bool_factor )? }

bool_factor { expression Logical_Operator expression }

Expand All @@ -51,6 +51,8 @@ bool_factor { expression Logical_Operator expression }
String { '"' (!["])* '"' }
space { @whitespace+ }
Comment { "/*" (![*/])* "*/" }
Or { "||" }
And { "&&" }
Logical_Operator { "==" | "!=" | "<" | "<=" | ">" | ">=" }
Expression_Operator { "+" | "-" }
Term_Operator { "*" | "/" | "%" }
Expand Down
36 changes: 24 additions & 12 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export class Parser {
}
}

// parte nova
private conditional(): ASTNode {
private bool_factor(): ASTNode {
const left = this.expr();

switch(this.currentToken.type) {
Expand Down Expand Up @@ -62,19 +61,32 @@ export class Parser {
const right = this.expr();
return new ConditionalNode(left, "<=", right, this.lexer.getCurrentLine(), this.lexer.getCurrentLineChar());
}
}

case TokenType.And: {
this.eat(this.currentToken.type);
const right = this.expr();
return new ConditionalNode(left, "&&", right, this.lexer.getCurrentLine(), this.lexer.getCurrentLineChar());
}
return left;
}

case TokenType.Or: {
this.eat(this.currentToken.type);
const right = this.expr();
return new ConditionalNode(left, "||", right, this.lexer.getCurrentLine(), this.lexer.getCurrentLineChar());
}
private bool_term(): ASTNode {
let left = this.bool_factor();

while(
this.currentToken.type === TokenType.And
) {
this.eat(TokenType.And);
left = new ConditionalNode(left, TokenType.And, this.bool_factor(), this.lexer.getCurrentLine(), this.lexer.getCurrentLineChar());
}

return left;
}

private conditional(): ASTNode {
let left = this.bool_term();

while(
this.currentToken.type === TokenType.Or
) {
this.eat(TokenType.Or);
left = new ConditionalNode(left, TokenType.Or, this.bool_term(), this.lexer.getCurrentLine(), this.lexer.getCurrentLineChar());
}

return left;
Expand Down

0 comments on commit 3f38afb

Please sign in to comment.