Skip to content

Commit

Permalink
e
Browse files Browse the repository at this point in the history
  • Loading branch information
BalaM314 committed May 3, 2024
1 parent 6a13887 commit f21ccb2
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/lexer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export declare const tokenNameTypeData: {
readonly ".": "punctuation.period";
readonly "\n": "newline";
};
export declare const tokenTextMapping: Record<"brace.open" | "brace.close" | "bracket.open" | "bracket.close" | "parentheses.open" | "parentheses.close" | "punctuation.colon" | "punctuation.semicolon" | "punctuation.comma" | "punctuation.period" | "boolean.true" | "boolean.false" | "keyword.declare" | "keyword.define" | "keyword.constant" | "keyword.output" | "keyword.input" | "keyword.call" | "keyword.if" | "keyword.then" | "keyword.else" | "keyword.if_end" | "keyword.for" | "keyword.to" | "keyword.for_end" | "keyword.step" | "keyword.while" | "keyword.while_end" | "keyword.dowhile" | "keyword.dowhile_end" | "keyword.function" | "keyword.function_end" | "keyword.procedure" | "keyword.procedure_end" | "keyword.return" | "keyword.returns" | "keyword.pass_mode.by_reference" | "keyword.pass_mode.by_value" | "keyword.type" | "keyword.type_end" | "keyword.open_file" | "keyword.read_file" | "keyword.write_file" | "keyword.close_file" | "keyword.get_record" | "keyword.put_record" | "keyword.seek" | "keyword.file_mode.read" | "keyword.file_mode.write" | "keyword.file_mode.append" | "keyword.file_mode.random" | "keyword.case" | "keyword.of" | "keyword.case_end" | "keyword.otherwise" | "keyword.class" | "keyword.class_end" | "keyword.new" | "keyword.super" | "keyword.inherits" | "keyword.class_modifier.private" | "keyword.class_modifier.public" | "keyword.array" | "keyword.set" | "newline" | "operator.add" | "operator.minus" | "operator.multiply" | "operator.divide" | "operator.mod" | "operator.integer_divide" | "operator.and" | "operator.or" | "operator.not" | "operator.equal_to" | "operator.not_equal_to" | "operator.less_than" | "operator.greater_than" | "operator.less_than_equal" | "operator.greater_than_equal" | "operator.assignment" | "operator.pointer" | "operator.string_concatenate", "." | "\n" | "+" | "-" | "*" | "/" | "(" | ")" | "[" | "]" | "<-" | "NEW" | "READ" | "WRITE" | "APPEND" | "RANDOM" | "AND" | "ARRAY" | "BYREF" | "BYVAL" | "CALL" | "CASE" | "CLASS" | "CLOSEFILE" | "CONSTANT" | "DECLARE" | "DEFINE" | "DIV" | "ELSE" | "ENDCASE" | "ENDCLASS" | "ENDFUNCTION" | "ENDIF" | "ENDPROCEDURE" | "ENDTYPE" | "ENDWHILE" | "FALSE" | "FOR" | "FUNCTION" | "GETRECORD" | "IF" | "INHERITS" | "INPUT" | "MOD" | "NEXT" | "NOT" | "OF" | "OPENFILE" | "OR" | "OTHERWISE" | "OUTPUT" | "PRIVATE" | "PROCEDURE" | "PUBLIC" | "PUTRECORD" | "READFILE" | "REPEAT" | "RETURN" | "RETURNS" | "SEEK" | "SET" | "STEP" | "SUPER" | "THEN" | "TO" | "TRUE" | "TYPE" | "UNTIL" | "WHILE" | "WRITEFILE" | ">=" | "<=" | "<>" | "=" | ">" | "<" | "^" | "&" | "{" | "}" | ":" | ";" | ",">;
export declare const tokenTextMapping: Record<"brace.open" | "brace.close" | "bracket.open" | "bracket.close" | "parentheses.open" | "parentheses.close" | "punctuation.colon" | "punctuation.semicolon" | "punctuation.comma" | "punctuation.period" | "boolean.true" | "boolean.false" | "keyword.declare" | "keyword.define" | "keyword.constant" | "keyword.output" | "keyword.input" | "keyword.call" | "keyword.if" | "keyword.then" | "keyword.else" | "keyword.if_end" | "keyword.for" | "keyword.to" | "keyword.for_end" | "keyword.step" | "keyword.while" | "keyword.while_end" | "keyword.dowhile" | "keyword.dowhile_end" | "keyword.function" | "keyword.function_end" | "keyword.procedure" | "keyword.procedure_end" | "keyword.return" | "keyword.returns" | "keyword.pass_mode.by_reference" | "keyword.pass_mode.by_value" | "keyword.type" | "keyword.type_end" | "keyword.open_file" | "keyword.read_file" | "keyword.write_file" | "keyword.close_file" | "keyword.get_record" | "keyword.put_record" | "keyword.seek" | "keyword.file_mode.read" | "keyword.file_mode.write" | "keyword.file_mode.append" | "keyword.file_mode.random" | "keyword.case" | "keyword.of" | "keyword.case_end" | "keyword.otherwise" | "keyword.class" | "keyword.class_end" | "keyword.new" | "keyword.super" | "keyword.inherits" | "keyword.class_modifier.private" | "keyword.class_modifier.public" | "keyword.array" | "keyword.set" | "newline" | "operator.add" | "operator.minus" | "operator.multiply" | "operator.divide" | "operator.mod" | "operator.integer_divide" | "operator.and" | "operator.or" | "operator.not" | "operator.equal_to" | "operator.not_equal_to" | "operator.less_than" | "operator.greater_than" | "operator.less_than_equal" | "operator.greater_than_equal" | "operator.assignment" | "operator.pointer" | "operator.string_concatenate", "." | "ELSE" | "REPEAT" | "READ" | "WRITE" | "APPEND" | "RANDOM" | "\n" | "NEW" | "ENDPROCEDURE" | "ENDFUNCTION" | "+" | "-" | "*" | "/" | "(" | ")" | "[" | "]" | "<-" | "AND" | "ARRAY" | "BYREF" | "BYVAL" | "CALL" | "CASE" | "CLASS" | "CLOSEFILE" | "CONSTANT" | "DECLARE" | "DEFINE" | "DIV" | "ENDCASE" | "ENDCLASS" | "ENDIF" | "ENDTYPE" | "ENDWHILE" | "FALSE" | "FOR" | "FUNCTION" | "GETRECORD" | "IF" | "INHERITS" | "INPUT" | "MOD" | "NEXT" | "NOT" | "OF" | "OPENFILE" | "OR" | "OTHERWISE" | "OUTPUT" | "PRIVATE" | "PROCEDURE" | "PUBLIC" | "PUTRECORD" | "READFILE" | "RETURN" | "RETURNS" | "SEEK" | "SET" | "STEP" | "SUPER" | "THEN" | "TO" | "TRUE" | "TYPE" | "UNTIL" | "WHILE" | "WRITEFILE" | ">=" | "<=" | "<>" | "=" | ">" | "<" | "^" | "&" | "{" | "}" | ":" | ";" | ",">;
type SymbolSpecifierFuncName = "isAlphanumeric" | "isNumber";
export declare function symbolize(input: string): SymbolizedProgram;
export declare function tokenize(input: SymbolizedProgram): TokenizedProgram;
Expand Down
2 changes: 1 addition & 1 deletion build/parser-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export declare class Operator implements IFormattable {
fmtDebug(): string;
}
export declare const operatorsByPriority: Operator[][];
export declare const operators: Omit<Record<"negate" | "subtract" | "access" | "pointer_reference" | "pointer_dereference" | "add" | "multiply" | "divide" | "mod" | "integer_divide" | "and" | "or" | "not" | "equal_to" | "not_equal_to" | "less_than" | "greater_than" | "less_than_equal" | "greater_than_equal" | "assignment" | "pointer" | "string_concatenate", Operator>, "assignment" | "pointer">;
export declare const operators: Omit<Record<"assignment" | "negate" | "subtract" | "access" | "pointer_reference" | "pointer_dereference" | "add" | "multiply" | "divide" | "mod" | "integer_divide" | "and" | "or" | "not" | "equal_to" | "not_equal_to" | "less_than" | "greater_than" | "less_than_equal" | "greater_than_equal" | "pointer" | "string_concatenate", Operator>, "assignment" | "pointer">;
export type TokenMatcher = TokenType | "." | "literal" | "literal|otherwise" | ".*" | ".+" | "expr+" | "type+" | "file_mode" | "class_modifier";
export type ProgramAST = {
program: string;
Expand Down
4 changes: 2 additions & 2 deletions build/statements.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export declare function StatementType(input: string): StatementType;
export type StatementCategory = "normal" | "block" | "block_end" | "block_multi_split";
export declare const statements: {
byStartKeyword: Partial<Record<"string" | "number.decimal" | "char" | "brace.open" | "brace.close" | "bracket.open" | "bracket.close" | "parentheses.open" | "parentheses.close" | "punctuation.colon" | "punctuation.semicolon" | "punctuation.comma" | "punctuation.period" | "name" | "boolean.true" | "boolean.false" | "keyword.declare" | "keyword.define" | "keyword.constant" | "keyword.output" | "keyword.input" | "keyword.call" | "keyword.if" | "keyword.then" | "keyword.else" | "keyword.if_end" | "keyword.for" | "keyword.to" | "keyword.for_end" | "keyword.step" | "keyword.while" | "keyword.while_end" | "keyword.dowhile" | "keyword.dowhile_end" | "keyword.function" | "keyword.function_end" | "keyword.procedure" | "keyword.procedure_end" | "keyword.return" | "keyword.returns" | "keyword.pass_mode.by_reference" | "keyword.pass_mode.by_value" | "keyword.type" | "keyword.type_end" | "keyword.open_file" | "keyword.read_file" | "keyword.write_file" | "keyword.close_file" | "keyword.get_record" | "keyword.put_record" | "keyword.seek" | "keyword.file_mode.read" | "keyword.file_mode.write" | "keyword.file_mode.append" | "keyword.file_mode.random" | "keyword.case" | "keyword.of" | "keyword.case_end" | "keyword.otherwise" | "keyword.class" | "keyword.class_end" | "keyword.new" | "keyword.super" | "keyword.inherits" | "keyword.class_modifier.private" | "keyword.class_modifier.public" | "keyword.array" | "keyword.set" | "newline" | "operator.add" | "operator.minus" | "operator.multiply" | "operator.divide" | "operator.mod" | "operator.integer_divide" | "operator.and" | "operator.or" | "operator.not" | "operator.equal_to" | "operator.not_equal_to" | "operator.less_than" | "operator.greater_than" | "operator.less_than_equal" | "operator.greater_than_equal" | "operator.assignment" | "operator.pointer" | "operator.string_concatenate", (typeof Statement)[]>>;
byType: Record<"function" | "type" | "assignment" | "if" | "for" | "for.step" | "while" | "dowhile" | "procedure" | "switch" | "class" | "class.inherits" | "class_function" | "class_procedure" | "input" | "output" | "declare" | "define" | "constant" | "return" | "call" | "type.pointer" | "type.enum" | "type.set" | "type.end" | "if.end" | "else" | "switch.end" | "case" | "case.range" | "for.end" | "while.end" | "dowhile.end" | "function.end" | "procedure.end" | "openfile" | "readfile" | "writefile" | "closefile" | "seek" | "getrecord" | "putrecord" | "class.end" | "class_property" | "class_procedure.end" | "class_function.end", typeof Statement>;
byType: Record<"function" | "declare" | "define" | "constant" | "assignment" | "output" | "input" | "return" | "call" | "type" | "type.pointer" | "type.enum" | "type.set" | "type.end" | "if" | "if.end" | "else" | "switch" | "switch.end" | "case" | "case.range" | "for" | "for.step" | "for.end" | "while" | "while.end" | "dowhile" | "dowhile.end" | "function.end" | "procedure" | "procedure.end" | "openfile" | "readfile" | "writefile" | "closefile" | "seek" | "getrecord" | "putrecord" | "class" | "class.inherits" | "class.end" | "class_property" | "class_procedure" | "class_procedure.end" | "class_function" | "class_function.end", typeof Statement>;
irregular: (typeof Statement)[];
};
export type PassMode = "value" | "reference";
Expand Down Expand Up @@ -379,7 +379,7 @@ interface IClassMemberStatement {
accessModifier: "public" | "private";
}
export declare class ClassStatement extends Statement {
static allowOnly: Set<"function" | "type" | "assignment" | "if" | "for" | "for.step" | "while" | "dowhile" | "procedure" | "switch" | "class" | "class.inherits" | "class_function" | "class_procedure" | "input" | "output" | "declare" | "define" | "constant" | "return" | "call" | "type.pointer" | "type.enum" | "type.set" | "type.end" | "if.end" | "else" | "switch.end" | "case" | "case.range" | "for.end" | "while.end" | "dowhile.end" | "function.end" | "procedure.end" | "openfile" | "readfile" | "writefile" | "closefile" | "seek" | "getrecord" | "putrecord" | "class.end" | "class_property" | "class_procedure.end" | "class_function.end">;
static allowOnly: Set<"function" | "declare" | "define" | "constant" | "assignment" | "output" | "input" | "return" | "call" | "type" | "type.pointer" | "type.enum" | "type.set" | "type.end" | "if" | "if.end" | "else" | "switch" | "switch.end" | "case" | "case.range" | "for" | "for.step" | "for.end" | "while" | "while.end" | "dowhile" | "dowhile.end" | "function.end" | "procedure" | "procedure.end" | "openfile" | "readfile" | "writefile" | "closefile" | "seek" | "getrecord" | "putrecord" | "class" | "class.inherits" | "class.end" | "class_property" | "class_procedure" | "class_procedure.end" | "class_function" | "class_function.end">;
name: Token;
constructor(tokens: [Token, Token] | [Token, Token, Token, Token]);
initializeClass(runtime: Runtime, branchNode: ProgramASTBranchNode): ClassVariableType;
Expand Down
2 changes: 1 addition & 1 deletion build/statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ let InputStatement = (() => {
if (!variable)
fail(`Undeclared variable ${this.name}`, this.tokens[1]);
if (!variable.mutable)
fail(`Cannot INPUT ${this.name} because it is a constant`);
fail(`Cannot INPUT ${this.name} because it is a constant`, this.tokens[1]);
const input = runtime._input(f.text `Enter the value for variable "${this.name}" (type: ${variable.type})`);
switch (variable.type) {
case PrimitiveVariableType.BOOLEAN:
Expand Down
1 change: 1 addition & 0 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ type StatementCheckFailResult = { message: string; priority: number; range: Text
*/
export const checkStatement = errorBoundary()((statement:typeof Statement, input:Token[]):
StatementCheckFailResult | StatementCheckTokenRange[] => {
//TODO rewrite to use modified wagner-fischer for best detection

if(input.length == 0) crash(`checkStatement() called with empty input`);
if(statement.category == "block_multi_split" && !statement.blockType) crash(`block_multi_split statements must have a block type specified.`);
Expand Down
2 changes: 1 addition & 1 deletion src/statements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export class InputStatement extends Statement {
run(runtime:Runtime){
const variable = runtime.getVariable(this.name);
if(!variable) fail(`Undeclared variable ${this.name}`, this.tokens[1]);
if(!variable.mutable) fail(`Cannot INPUT ${this.name} because it is a constant`);
if(!variable.mutable) fail(`Cannot INPUT ${this.name} because it is a constant`, this.tokens[1]);
const input = runtime._input(f.text`Enter the value for variable "${this.name}" (type: ${variable.type})`);
switch(variable.type){
case PrimitiveVariableType.BOOLEAN:
Expand Down

0 comments on commit f21ccb2

Please sign in to comment.