Information processing device, inspection method, inspection program, and server
Patent Information
- Application Number
- JP2020051540
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2020-03-23
- Publication Date
- 2025-02-19
- Estimated Expiration
- 2040-03-23
AI Technical Summary
【0008】 ユーザにとって好ましいタイミングで構文の検査を実行することができる。
Smart Images

Figure 0007631667000001 
Figure 0007631667000002 
Figure 0007631667000003
Abstract
Description
[Technical field]
[0001] The present invention relates to an information processing device, an inspection method, an inspection program, and a server. [Background technology]
[0002] Conventionally, syntax checking programs are known that check the syntax of a coded program and notify the user of any errors in the syntax in order to support program development. Syntax checking programs are prepared for each program language, and representative syntax checking programs include an interpreter and a compiler. For example, an interpreter checks the syntax of a program to be executed when an instruction to execute the program is input. If no syntax errors are detected as a result of the syntax check, the interpreter then checks for execution errors, and if no execution errors are detected, the interpreter executes the program and outputs the execution results.
[0003] In this regard, a technique relating to checking for syntax errors in a program is known (for example, Patent Document 1). [Prior art documents] [Patent documents]
[0004] [Patent Document 1] Japanese Patent Application Publication No. 3-288238 Summary of the Invention [Problem to be solved by the invention]
[0005] However, the timing of checking for syntax errors does not necessarily have to be limited to when the user inputs an instruction to execute a program, but there has been no technology that allows checking of syntax at a time that is convenient for the user.
[0006] In one aspect, the present invention has an object to execute syntax checking at a timing convenient for a user. [Means for solving the problem]
[0007] According to an embodiment of the present invention, there is provided an information processing apparatus comprising: a reception unit that receives an input of an operation for editing a program displayed on a display screen; and when the reception unit receives an input of a focus line change operation for changing a focus line from a certain line in the program to another line, the information processing apparatus targets the program code described in the certain line. to check for syntax errors a verification unit for performing syntax checking; wherein the inspection unit executes at least one of a first control of adding, to the program code of the certain line, program code of a line that satisfies a predetermined condition and is located before or after the program code of the certain line, when the program code of the certain line includes a character string that satisfies a first condition, and then executing the syntax check, or a second control of editing the program code of the certain line, when the program code of the certain line includes a character string that satisfies a second condition, and then executing the syntax check. . In addition, an information processing device according to one embodiment of one aspect of the present invention includes a reception unit that receives input of an operation for editing a program displayed on a display screen, and an inspection unit that, when the reception unit receives input of a focus line change operation that changes a focus line from a certain line in the program to another line, performs a syntax check to check for syntax errors on the program code written in the certain line, and operates in an operating mode including an edit mode in which editing of the program is accepted, and an execution mode in which the program is executed, wherein, when the focus line change operation is input to the reception unit while operating in the edit mode, the inspection unit performs a syntax check on the program code written in the certain line, and if an error is detected in the syntax check, the inspection unit allows editing of the program code written in the certain line while still operating in the edit mode, and when the focus line change operation is re-input to the reception unit after the program code written in the certain line is edited, it re-executes the syntax check on the edited program code written in the certain line. Effect of the Invention
[0008] The syntax check can be performed at a time convenient to the user. [Brief description of the drawings]
[0009] [Figure 1] FIG. 1 is a diagram illustrating an example of an information processing apparatus according to an embodiment. [Diagram 2] FIG. 1 is a diagram illustrating a block configuration of an information processing device according to an embodiment. [Diagram 3] 3A to 3C are diagrams illustrating examples of an edit mode and an execution mode in which the information processing device according to the embodiment operates. [Figure 4] 11 is a diagram illustrating an example of an operational flow of a syntax check process according to the embodiment. FIG. [Diagram 5] FIG. 13 is a diagram illustrating a display screen including an error display according to the embodiment. [Figure 6] FIG. 2 is a diagram illustrating an example of a hardware configuration of a computer for implementing the information processing device according to the embodiment. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0010] Hereinafter, several embodiments of the present invention will be described in detail with reference to the drawings. Note that the same reference numerals are used to designate corresponding elements in the various drawings.
[0011] FIG. 1 is a diagram showing an example of an information processing device 100 according to an embodiment. In FIG. 1, a scientific calculator is illustrated as the information processing device 100. In the example of FIG. 1, the information processing device 100 includes various keys 101 having function keys (for example, F1 to F6), function keys, numeric keys, arithmetic keys, and other functions. The keys 101 also include, for example, a movement key 102 for moving an input position indicated by a cursor or a line of interest such as a line to be input, and an EXE key 103 for instructing the execution of an operation by the calculator. Note that the information processing device 100 may operate, for example, in an edit mode for accepting operation input for creating and editing a program and an execution mode for executing a program. The EXE key 103 may be used, for example, as a key for inputting a line feed code in the edit mode.
[0012] The display screen 105 may be a screen that displays characters and images, and the information processing device 100 may display on the display screen 105 a program editing screen or execution screen.
[0013] The information processing device 100 is not limited to the scientific calculator exemplified in Fig. 1. The information processing device 100 may be other devices having a program editing function and execution function, such as a personal computer (PC), a mobile PC, a tablet terminal, a smartphone, a mobile phone, or a server.
[0014] FIG. 2 is a diagram illustrating a block configuration of the information processing device 100 according to the embodiment. The information processing device 100 includes, for example, a control unit 201, a storage unit 202, a display unit 203, and an input unit 204. The control unit 201 includes, for example, a reception unit 211 and an inspection unit 212, and may also include other functional units. The storage unit 202 stores information such as a syntax inspection program and a program describing the procedure of an operation flow described later. The display unit 203 is, for example, a device that displays information such as a display. The display unit 203 displays information on the display screen 105 according to, for example, an instruction from the control unit 201. The input unit 204 is, for example, a device that accepts input from a user. The input unit 204 may be, for example, the key 101, or may be another input device such as a touch panel. Details of each of these units and details of the information stored in the storage unit 202 will be described later.
[0015] 3 is a diagram illustrating an example of an edit mode and an execution mode in which the information processing device 100 according to the embodiment operates. As shown in FIG. 3, the information processing device 100 includes, as operation modes for programming, an edit mode in which editing of a program is accepted, and an execution mode in which a program is executed.
[0016] In the edit mode, the control unit 201 accepts input of operations for editing a program, and the user can input a program by, for example, operating the keys 101 of the information processing device 100 (FIG. 3(1)). When an execution instruction is input for a program created in the edit mode, the mode is switched and the mode transitions to the execution mode (FIG. 3(2)).
[0017] In the execution mode, the control unit 201 first performs a syntax check on the program to check whether the program contains any syntax errors (FIG. 3(3)). If the program does not contain any syntax errors, the control unit 201 then checks the program for execution errors (FIG. 3(4)).
[0018] If an error is found as a result of the syntax check and execution error check, the control unit 201 displays the contents of the error on the display screen 105 (FIG. 3(5)). On the other hand, if the program does not contain any errors, the control unit 201 displays the results of program execution on the display screen 105 (FIG. 3(5)). Then, when an instruction to switch to edit mode is input in the execution mode (FIG. 3(6)), the control unit 201 transitions the mode to edit mode.
[0019] In this way, by switching between the edit mode and the execution mode in the information processing device 100, the user can create a program and check the results of its execution.
[0020] Furthermore, in the embodiment, the control unit 201 also checks the syntax in the edit mode. For example, assume that while the user is creating a program, an input is made for an operation to change the line of interest from one line in the program to another line. In this case, the control unit 201 may detect the input of the operation to change the line of interest from one line to another line (FIG. 3(7)), and perform a syntax check in the edit mode (FIG. 3(8)). Then, if a syntax error is detected, the control unit 201 displays the contents of the syntax error on the display screen 105 (FIG. 3(9)).
[0021] In addition, the focus line change operation for changing the focus line from one line to another line in a program may be, for example, a cursor movement operation for moving the cursor to another line. In the following, as a focus line change operation for changing the focus line from one line to another line in a program, an operation for moving the cursor to another line will be described as an example. Here, the operation for moving the cursor to another line may include, for example, an operation for instructing the movement by the movement key 102, such as "↑" for moving the cursor position to an upper line, or "↓" for moving the cursor position to a lower line. In addition, the operation for moving the cursor to another line may include, for example, an operation for inputting a line feed code. Furthermore, the operation for moving the cursor to another line may include, for example, an input operation of a shortcut key for moving the cursor to the first or last line, an operation for moving the cursor by searching for a character string, or the like. In this case, the control unit 201 may detect the input of the line movement operation (FIG. 3(7)) and execute a syntax check in the edit mode (FIG. 3(8)). If a syntax error is detected, the control unit 201 displays the content of the syntax error on the display screen 105 (FIG. 3(9)).
[0022] In this case, the target of syntax check may be, for example, the line from which the cursor was moved when an operation to move the cursor to another line was input. For example, when a user inputs program code, the operation to move the cursor to another line is often input at the timing when the user determines that input of the program code of that line is completed. Therefore, as described above, by detecting the input of the operation to move the cursor to another line and checking the syntax of the line from which the cursor was moved at that timing, syntax check can be performed on the line that the user has just completed inputting. If a syntax error exists, the syntax error can be notified. Therefore, the user can easily recognize the contents of his / her input in correspondence with the result of the syntax error, and can recognize his / her programming mistake at a timing when the learning effect of programming is high. In addition, by extracting the program code of the line from which the cursor was moved and performing syntax check in this way, the processing load required for executing syntax check can be reduced while efficiently checking the line where input was performed.
[0023] As another example of the timing for executing the syntax check, it is possible to automatically execute the syntax check when no operation such as character input is performed for a predetermined time. However, if the syntax check is executed at such a timing, the syntax check will be executed when the time comes even when the user has not completed inputting one line of program code. In this case, since the input of one line has not yet been completed, a syntax error will be notified, but even if an error is notified in a situation where the user recognizes that such an error should occur, the user cannot expect a learning effect. Furthermore, if an error notification is frequently repeated in a situation where such an error should occur, the user will lose interest in the error notification that he or she should recognize, and there is a risk that the learning effect will be reduced. Furthermore, since the syntax check will be executed after a certain time has passed, the syntax check will be executed more than necessary, which will unnecessarily increase the processing load.
[0024] As another alternative timing for executing syntax check, for example, a shortcut key for executing syntax check may be set in advance, and the user may execute syntax check at a timing desired by the user. However, if execution of syntax check is left to the user in this way, the user may become accustomed to the task and may neglect to execute syntax check. Therefore, there is a need for a further technique for executing syntax check at a timing preferred by the user.
[0025] As described above, in the embodiment, when a predetermined operation to move the cursor to another line is input, the syntax check is executed. Therefore, even if the user is not aware of the execution of the syntax check, the syntax check can be executed at an appropriate timing with a high learning effect. Also, according to the embodiment, for example, the syntax check is executed at the timing when the user completes input of one line of program code and inputs a line movement operation. Therefore, compared to the case where the syntax check is executed automatically, the syntax check can be executed efficiently at an appropriate number of times while suppressing the processing load. For example, the information processing device 100 such as a scientific calculator may have a low processing capacity. Even in such a case, the syntax check can be executed at an appropriate timing while suppressing the processing load, and the user can program without being aware of the processing delay, and can be notified of the result of the syntax check.
[0026] The syntax check may be performed by, for example, the control unit 201 running the program code of the area to be checked by a syntax check program. The syntax check program may include, for example, an interpreter, a compiler, etc. Since the syntax of a program may differ depending on the programming language, a syntax check program may be prepared depending on the programming language. In the following, an example will be described in which the programming language is Python, but the programming language that can be used in the embodiment is not limited to Python, and the embodiment can also be applied to cases in which other languages such as C and Perl are used.
[0027] Next, execution of syntax check when a cursor line movement operation is input according to the embodiment will be further described. As described above, in one embodiment, when a cursor line movement operation is input, a syntax check is executed on the program code of the line from which the cursor is moved. By extracting the program code of the line from which the cursor is moved and executing a syntax check in this way, the processing load required for executing the syntax check can be reduced while efficiently checking the line on which the input is performed.
[0028] However, for example, when executing a syntax check of program code, depending on the instructions written in the program code, the syntax check program may refer to the previous or following line of program code. And, for example, when a syntax check program refers to program code spanning multiple lines in such a syntax check, if only one line of program code is extracted and subjected to syntax check, it may be determined to be a syntax error even if a syntax check of the entire program would not result in a syntax error.
[0029] Therefore, in the embodiment, when the program code on the line from which the cursor is moved contains a predetermined character string indicating an instruction that refers to program code across multiple lines in a syntax check, the control unit 201 processes the program code before subjecting it to a syntax check. Note that the character string may be data having a structure in which one or more characters and symbols, as well as codes such as line feed codes, are arranged, for example.
[0030] Examples of the types of processing that can be performed on the program code of the line from which the cursor is moved include the following: (1) Get and add the program code from the line before or after the line from which the cursor is moved (2) Edit the program code on the line from which the cursor is moved
[0031] The above types of editing will be explained below using an example in which the programming language is Python.
[0032] (1) Get and add the program code from the line before or after the line from which the cursor is moved If the program code of the line from which the cursor is moved contains a character string that satisfies a first condition, the control unit 201 acquires the program code of a line that satisfies a predetermined condition and is located before or after the program code of the line from which the cursor is moved. The control unit 201 then adds the acquired program code to the program code of the line from which the cursor is moved, and then has the syntax check program process it to check for syntax errors. This allows the syntax check program to perform syntax check by referring to information about the program code of the previous or following line, and makes it possible to avoid the occurrence of syntax errors caused by extracting the program code of the line from which the cursor is moved.
[0033] The first condition may be, for example, a condition for detecting an instruction that refers to information on a previous or subsequent line during syntax checking. For example, in Python, in syntax checking of a line that includes character strings such as "else", "elif", "break", "return" and "continue", information on the program code of the previous line is referenced. In this case, if there is no information on the program code of the previous line, it is determined to be a syntax error. Therefore, when the program code of the line from which the cursor is moved includes character strings such as "else", "elif", "break", "return" and "continue", the control unit 201 acquires program code from the program code located before the line from which the cursor is moved up to the nearest line that has the same number of indents. The control unit 201 may add the acquired program code to the program code of the line from which the cursor is moved and then have the syntax checking program process it to check for syntax errors.
[0034] For example, if the program code of the line from which the cursor is moved contains "else," the control unit 201 searches for the nearest line that is indented the same number as the number of indents of "else," and identifies a line that contains an "if" of an if statement that is indented the same number. Then, the control unit 201 may run the program code from the identified "if" line to the "else" line through a syntax check program.
[0035] Here, the case where the program code of the line before the line where the cursor is located is acquired and added to the program code of the line from which the cursor is moved is exemplified, but the embodiment is not limited to this. For example, it is assumed that the program code of the line from which the cursor is moved includes an instruction that refers to the program code of the line after the line from which the cursor is moved in the syntax check. In this case, the control unit 201 may check for syntax errors by adding the program code of the subsequent line to the program code of the line from which the cursor is moved and then having the syntax check program process it. In this case, the control unit 201 may, for example, search for the line after the line from which the cursor is moved, acquire program code up to the line immediately before the line found in the search that has the same number of indents, add it to the program code of the line from which the cursor is moved, and perform syntax check. Thereby, the syntax check program can execute syntax check by referring to the information of the program code of the subsequent line, and can avoid the occurrence of syntax errors caused by extracting the program code of the line from which the cursor is moved.
[0036] (2) Edit the program code on the line from which the cursor is moved Editing the program code in the line from which the cursor is moved may include, for example, adding, deleting, and replacing character strings in the program code in the line from which the cursor is moved.
[0037] For example, in Python, when compound statements are written using commands such as "if", "for" and "def", the number of indents at the beginning of lines must be the same for the same block. However, if only lines with spaces at the beginning of the lines are extracted and subjected to syntax checking, the syntax checking program will determine that there is a syntax error. Therefore, in the embodiment, when the program code of the line from which the cursor is moved contains spaces at the beginning of the line, the control unit 201 may delete the spaces at the beginning of the line and then subject the program code of the line from which the cursor is moved to the syntax checking program. This makes it possible to avoid the syntax checking program detecting a syntax error due to the extraction of the program code of the line from which the cursor is moved when the beginning of the program code of the line from which the cursor is moved is indented.
[0038] As described in (1) above, when program code of a line before or after the line from which the cursor is moved based on the number of indents and is added to the program code of the line from which the cursor is moved, the control unit 201 may also delete indents of the program code to be added that have the same number of indents as the line from which the cursor is moved.
[0039] As described above, the syntax check program may refer to program code on other lines when determining whether a syntax error has occurred. In this case, a syntax error can be avoided by adding a predetermined character string or the like that functions as a reference to the program code on the line from which the cursor is moved. For example, in Python, when describing a compound statement using commands such as "if", "for", and "def", if a block continues on the next line, it is a rule to write ":" at the end of the line. Therefore, for example, if the program code on the line from which the cursor is moved ends with ":", it can be determined that the syntax check program refers to the program code on a line that follows the program code on the line from which the cursor is moved in the syntax check. In this case, in the embodiment, the control unit 201 may edit the program code on the line from which the cursor is moved. For example, if the line from which the cursor is moved ends with ":", the control unit 201 may avoid a syntax error by adding "pass" or the like as the contents of the block after ":". This makes it possible to check the syntax in the lines other than the added "pass".
[0040] For example, in addition to "if", "for", and "def", "else" and "elif" may also have ":" written at the end of a line of program code. In this case, the control unit 201 may add "pass" to the end of the line to avoid a syntax error. As described in (1) above, the control unit 201 may also obtain program code on a line after the line from which the cursor is moved and add it to the program code on the line from which the cursor is moved, to avoid a syntax error.
[0041] As described above, in an embodiment, the control unit 201 may avoid syntax errors caused by extracting the program code of the line from which the cursor is moved, by processing the program code of the line from which the cursor is moved.
[0042] The operation flow of the syntax check process according to the embodiment will be described below. Fig. 4 is a diagram illustrating an example of the operation flow of the syntax check process according to the embodiment. For example, when the control unit 201 transitions to the edit mode, the control unit 201 may start the operation flow of Fig. 4.
[0043] In step 401 (hereinafter, step is abbreviated as "S", e.g., S401), the control unit 201 executes a syntax check on the entire text of a file opened in edit mode. For example, when a file created in the past is opened, program code may already be written in the file opened in edit mode. In such a case, the control unit 201 may check for syntax errors in the program code written in the opened file.
[0044] In S402, the control unit 201 determines whether or not the test target contains a syntax error as a result of the test by the syntax check program. If a syntax error is not contained (NO in S402), the flow proceeds to S404. On the other hand, if a syntax error is contained (YES in S402), the flow proceeds to S403, where the control unit 201 displays the syntax error test result on the display screen 105 of the display unit 203, and notifies the user of the syntax error. For example, the control unit 201 may display the line where the syntax error was first found in the program and the content of the syntax error on the display screen 105. The control unit 201 may also move the cursor to the line where the syntax error was first found in the program. Once the control unit 201 displays the syntax error test result, the flow proceeds to S404.
[0045] In S404, the control unit 201 accepts an input from a user. For example, the user may edit a program by inputting an operation via the input unit 204 such as the key 101 provided in the information processing device 100. When the input from the user is accepted, the flow proceeds to S405.
[0046] In S405, the control unit 201 determines whether the input operation is a predetermined line movement operation for moving the cursor to another line of the program. The predetermined line movement operation may include, for example, at least one of the following: input of an operation for moving the cursor position up or down, input of a line feed code, input by a shortcut key for moving the cursor to the first line or the last line, input of line movement by search, etc. If the input is not the predetermined line movement operation (NO in S405), the flow proceeds to S415. In S415, the control unit 201 executes the input operation, and then the flow returns to S404 to repeat the process. On the other hand, if the input is the predetermined line movement operation (YES in S405), the flow proceeds to S406.
[0047] In S406, the control unit 201 acquires the program code of the line from which the cursor is moved when a predetermined line movement operation is input.
[0048] In S407, the control unit 201 determines whether the program code of the source line includes a character string that satisfies a first condition. The first condition may be, for example, a condition for detecting an instruction in which information on a previous or subsequent line is referenced during syntax check. If the program code of the source line does not include a character string that satisfies the first condition (NO in S407), the flow proceeds to S409. On the other hand, if the program code of the source line includes a character string that satisfies the first condition (YES in S407), the flow proceeds to S408. In S408, the control unit 201 adds the program code of the previous or subsequent line that is referenced during syntax check to the program code of the source line, and the flow proceeds to S409.
[0049] For example, if the program language is Python, when the program code of the line to be inspected includes "else", "elif", "break", "return", and "continue", the syntax check program refers to the information of the previous line in the syntax check. As an example, if the program code of the line to be inspected includes "else" and "elif", the syntax check program checks whether there is an "if" corresponding to the "else" or "elif" before the "else" or "elif" in the syntax check. Therefore, for example, when the program code of the line to be inspected includes a character string such as "else" or "elif", the control unit 201 may extract the program code up to the line including the nearest "if" having the number of indents that matches the number of indents added to the "else" or "elif". Similarly, when the program code of the line to be inspected includes a character string such as "break", "return", and "continue", the control unit 201 may specify the range of the previous line to be referenced in the syntax check based on information such as the number of indents and the block of a compound statement, and obtain the program code of that range.
[0050] Next, in S409, the control unit 201 determines whether the program code of the source line includes a character string that satisfies a second condition. The second condition may be, for example, a condition for detecting a character string that needs to be edited in the program code in the line during syntax checking. For example, if the program code of the source line does not include a character string that satisfies the second condition (NO in S409), the flow proceeds to S411. On the other hand, for example, if the program code of the source line includes a character string that satisfies the second condition (YES in S409), the flow proceeds to S410. In S410, the control unit 201 edits the character string in the line, and the flow proceeds to S411.
[0051] The second condition for detecting an instruction that requires editing of a character string in a line may include a ":" at the end of the line if the programming language is Python as described above. In this case, the control unit 201 may add "pass" after the ":" at the end of the line. Alternatively, the second condition may be that the program code of the line to be inspected contains a space at the beginning of the line, in which case the control unit 201 deletes the space at the beginning of the line. When deleting the space at the beginning of the line, for example, if multiple lines have been extracted as the program code of the line to be inspected in the process of S408, the control unit 201 may also delete the spaces at the beginning of other lines that have the same indent number as the program code of the line from which the cursor is moved.
[0052] Then, in S411, the control unit 201 executes a syntax check on the program code of the line to be checked. For example, if both S407 and S409 are determined to be NO, the program code of the line to be checked may be the program code of the line from which the cursor was moved. On the other hand, if the program code of the line from which the cursor was moved has been modified in at least one of the processes of S408 and S410, the control unit 201 may execute a syntax check on the modified program code as the program code of the line to be checked.
[0053] Then, if there is no syntax error in S412 (NO in S412), the flow proceeds to S413. In S413, the control unit 201 moves the cursor to a position corresponding to the line movement operation input in S404, and the flow returns to S404. On the other hand, if there is a syntax error in S412 (YES in S412), the flow proceeds to S414. In S414, the control unit 201 displays the detected syntax error on the display screen 105, and the flow returns to S404. In this case, since it is estimated that the source line contains a syntax error, the control unit 201 may not execute the line movement operation input in S404, and may leave the cursor position displayed on the source line.
[0054] For example, as described above, according to the operational flow of FIG. 4, when a predetermined line movement operation for moving the cursor to another line of the program is input, the control unit 201 can perform syntax checking on the program code of the line from which the cursor is moved.
[0055] FIG. 5 is a diagram illustrating a display screen 500 including an error display according to the embodiment. The display screen 500 may be displayed on the display screen 105 of the display unit 203 of the information processing device 100 in S414, for example. In the example of FIG. 5(a), the display screen 500 includes an editing area 501 and a cursor 502. The editing area 501 is, for example, a display area where editing of a program is performed. Furthermore, the cursor 502 indicates, for example, an editing position of the program in the editing area 501. In the example of FIG. 5(a), a Python program with a total of three lines is displayed on the display screen 500. Furthermore, the cursor 502 is displayed at the end of the third line of the program code.
[0056] Here, for example, assume that the user inputs an operation to move the cursor 502 to another line by, for example, pressing the EXE key 103 of the information processing device 100 to input a line feed code. In this case, as described in the operation flow of FIG. 4, the control unit 201 executes a syntax check of the program code on the third line. Then, in the example of FIG. 5(a), the program code on the third line does not have a "(" corresponding to the ")" at the end, so it is determined to be a syntax error by the syntax check program, and "x" is displayed as error information 503 indicating that a syntax error has been detected. Also, in the example of FIG. 5(a), the line number: 003 is displayed as an error line 504 indicating the line where the error was detected. Therefore, the user can know that there is a syntax error in the program code on the third line that he was currently inputting at the timing when he inputs the operation to move the line.
[0057] In this way, by performing a syntax check when the user determines that input of a line of program code is complete and notifying the user, the user can learn about any syntax errors that exist in the program code that he or she has just input, which is expected to have a significant learning effect.
[0058] 5(a), when a syntax error is detected, the control unit 201 may cancel the movement of the cursor 502 corresponding to the input move operation, and may leave the cursor displayed in the line from which the move operation was input. This allows the user to immediately correct the program code in the line where the error was detected.
[0059] On the other hand, if no syntax error is detected, the control unit 201 executes the movement of the cursor 502 corresponding to the input movement operation, so that if the user has input a program with correct syntax, he or she can continue programming without being aware that a syntax check has been executed.
[0060] As described with reference to FIG. 3, in the embodiment, the syntax check is performed in the edit mode, so that when editing the program and performing the syntax check, the program code can be corrected without performing unnecessary operations such as switching between modes. For example, in FIG. 5(a), if the user corrects the third line to "print("again!")" and inputs an operation to move the cursor 502 to another line again, the control unit 201 performs the syntax check again on the program code in the third line. Then, if no error is detected as a result of performing the syntax check again, the control unit 201 moves the cursor 502 to another line. In this way, according to the embodiment, the syntax check is performed on the program code for each line, and the user is notified of syntax errors until no syntax errors are detected, so that the degree of completion of each line of the program code can be improved when creating a program. As a result, the degree of completion of the entire program can also be efficiently improved.
[0061] The error information 503 and the error line 504 according to the embodiment are not limited to the example shown in Fig. 5(a). For example, in another embodiment, the control unit 201 may notify the error information 503 and the error line 504 on a display screen 510 for notifying an error, as shown in a display screen 510 shown in Fig. 5(b). The display screen 510 may be displayed in S403, for example.
[0062] In the above, an example is described in which the function of syntax check according to the embodiment is implemented in the information processing device 100 having a program editing function and an execution function, but the embodiment is not limited to this. For example, the above-mentioned function of syntax check may be implemented in an editor application or the like that runs on the information processing device 100. Alternatively, for example, the function of syntax check according to the embodiment may be implemented in a programming learning service provided by a server on a network.
[0063] In the above embodiment, a cursor movement operation for moving the cursor to another line is described as an example of a line change operation for changing a line of interest from one line to another line in a program. However, the embodiment is not limited to this. For example, something other than the cursor may be used to indicate a line of interest, such as a line to be input. As an example, a line of interest may be highlighted by displaying the entire line of interest in a color different from the colors of other lines, thereby identifying the line of interest. For example, even in such a case, when a line change operation for changing a line of interest from one line to another line in a program is input, a syntax check according to the embodiment may be performed.
[0064] As described above, according to the above embodiment, the control unit 201 accepts input of an operation for editing a program displayed on the display screen 105. Then, when the control unit 201 accepts input of a focus line change operation for changing a focus line from one line in a program to another line, the control unit 201 executes a syntax check on the program code written in a certain line. Therefore, it is possible to execute a syntax check on the line that the user has just finished inputting.
[0065] In the above embodiment, when the control unit 201 receives an input of a target line change operation, the control unit 201 extracts the program code of a certain line that is the target line from the program, and checks for syntax errors by having a syntax check program process the extracted program code of the certain line. Therefore, the target line can be efficiently checked while reducing the processing load required for executing the syntax check.
[0066] Also, for example, it is assumed that the program code of a certain line that is a line of interest contains a character string that satisfies a first condition. The first condition may be, for example, a condition for detecting an instruction that refers to information of a previous or subsequent line during syntax checking. In this case, according to the above-described embodiment, the control unit 201 checks for syntax errors by adding the program code of a line that satisfies a predetermined condition and is located before or after the program code of the certain line to the program code of the certain line, and then having the syntax checking program process the program code. This makes it possible to avoid the occurrence of syntax errors caused by extracting the program code of the certain line.
[0067] Also, for example, it is assumed that the program code of a certain line that is the line of interest contains a character string that satisfies a second condition. The second condition may be, for example, a condition for detecting a character string that requires editing in the program code in the line during syntax checking. In this case, according to the above-mentioned embodiment, the control unit 201 checks for syntax errors by editing the program code of the certain line and then having the syntax checking program process it. This makes it possible to avoid the occurrence of syntax errors caused by extracting the program code of the line of interest.
[0068] In the above embodiment, the information processing device 100 operates in an operation mode including, for example, an edit mode in which editing of a program is accepted and an execution mode in which a program is executed. Then, when an operation to change a line of interest is input during operation in the edit mode, the control unit 201 executes a syntax check on the program code described in a line that is the line of interest. If an error is detected in the syntax check, the control unit 201 allows editing of the program code described in a line while operating in the edit mode. Then, when an operation to change a line of interest is input again after editing the program code described in a line, the control unit 201 executes a syntax check again on the edited program code described in the line. Therefore, the completeness of the entire program can be efficiently improved.
[0069] Although the embodiment has been exemplified above, the embodiment is not limited thereto. For example, the above-mentioned operation flow is an example, and the embodiment is not limited thereto. If possible, the operation flow may be executed by changing the order of the processes, may include additional processes, or may omit some processes. For example, depending on the situation, such as when creating a new file for recording a program, the processes from S401 to S403 in FIG. 4 may not be executed.
[0070] In the above embodiment, the example is described in which the target of syntax check is the line from which the cursor is moved when an input is made to move the cursor to another line, but the embodiment is not limited to this. In another embodiment, the control unit 201 may execute syntax check on another range including other than the line from which the cursor is moved, such as the entire text of the program.
[0071] Also, for example, a program may include a commented out area in which the creator of the program writes notes, etc. For example, in Python, the content written from "#" to the end of the line in a program is ignored at execution time. Therefore, in the above-mentioned embodiment, in the case of a program and program code, a commented out area that is ignored in syntax checking may not be included. For example, in the process of S409 described above, a determination may be made as to whether the end of a line in the program code written before the commented out area is ":".
[0072] In the above embodiment, the execution of a syntax check when an operation to move the cursor to another line is input does not necessarily have to be executed for all operations that move the cursor to another line. For example, the control unit 201 does not have to execute a syntax check for input of an operation to move some of the cursor to another line.
[0073] In addition, in the above-mentioned embodiment, the programming language is Python, but the embodiment is not limited to this, and can be applied to other languages such as C language, Perl, etc. In that case, for example, in the above-mentioned Python, an example is described in which the range of program code to be extracted from the previous and next lines is specified by indentation, but in C language, Perl, etc., the range of program code to be extracted may be specified by parentheses.
[0074] Fig. 6 is a diagram illustrating a hardware configuration of a computer 600 for realizing the information processing device 100 according to the embodiment. The hardware configuration for realizing the information processing device 100 in Fig. 6 includes, for example, a processor 601, a memory 602, a storage device 603, a reading device 604, a communication interface 606, an input / output interface 607, an input device 611, and a display device 612. The processor 601, the memory 602, the storage device 603, the reading device 604, the communication interface 606, and the input / output interface 607 are connected to each other via, for example, a bus 608.
[0075] The processor 601 may be, for example, a single processor, or a multi-processor or multi-core. The processor 601 provides some or all of the functions of the control unit 201 described above by using the memory 602 to execute a program describing, for example, the procedure of the above-mentioned operation flow. For example, the processor 601 of the information processing device 100 may operate as the reception unit 211 and the inspection unit 212 by reading and executing a program stored in the storage device 603. The processor 601 may also perform syntax inspection of the program by executing a syntax inspection program.
[0076] The memory 602 is, for example, a semiconductor memory, and may include a RAM area and a ROM area. The storage device 603 is, for example, a semiconductor memory such as a hard disk or a flash memory, or an external storage device. Note that RAM is an abbreviation for Random Access Memory. Also, ROM is an abbreviation for Read Only Memory.
[0077] The reader 604 accesses the removable storage medium 605 according to an instruction from the processor 601. The removable storage medium 605 is realized by, for example, a semiconductor device, a medium in which information is input and output by magnetic action, or a medium in which information is input and output by optical action. The semiconductor device is, for example, a Universal Serial Bus (USB) memory. The medium in which information is input and output by magnetic action is, for example, a magnetic disk. The medium in which information is input and output by optical action is, for example, a CD-ROM, DVD, Blu-ray Disc, etc. (Blu-ray is a registered trademark). CD is an abbreviation for Compact Disc. DVD is an abbreviation for Digital Versatile Disk.
[0078] The storage unit 202 may include, for example, a memory 602, a storage device 603, and a removable storage medium 605. For example, the storage device 603 of the information processing device 100 stores a syntax check program, a program describing the procedures of the above-mentioned operation flow, and the like.
[0079] The communication interface 606 communicates with other devices via wired or wireless communication according to instructions from the processor 601 .
[0080] The input / output interface 607 may be, for example, an interface between a device that performs input and output. In the example of FIG. 6, the input / output interface 607 is connected to an input device 611. The input device 611 is, for example, a device such as a key, a button, a keyboard, a touch panel, a microphone, or a camera that receives instructions from a user. Note that, in one example, the microphone may be used for voice input. Also, in one example, the camera may be used for gesture input. The input device 611 is an example of the above-mentioned input unit 204. Also, in the example of FIG. 6, the input / output interface 607 is connected to a display device 612. The display device 612 may be, for example, a device that performs display such as a display or a projector, and displays information on a display screen according to an instruction from the processor 601. The display device 612 is an example of the above-mentioned display unit 203. Also, the input / output interface 607 may be connected to other devices such as, for example, an audio device such as a speaker, and a printing device such as a printer.
[0081] Each program according to the embodiment is provided to the information processing device 100 in the following form, for example. (1) Pre-installed in storage device 603. (2) Provided by a removable storage medium 605. (3) Provided from a server 630 such as a program server via a network 620.
[0082] Note that the hardware configuration of the computer 600 for realizing the information processing device 100 described with reference to FIG. 6 is an example, and the embodiment is not limited thereto. For example, a part of the above-mentioned configuration may be deleted, or a new configuration may be added. Also, in another embodiment, for example, a part or all of the functions of the above-mentioned control unit 201 may be implemented as hardware using FPGA, SoC, ASIC, PLD, or the like. Note that FPGA is an abbreviation for Field Programmable Gate Array. SoC is an abbreviation for System-on-a-chip. ASIC is an abbreviation for Application Specific Integrated Circuit. PLD is an abbreviation for Programmable Logic Device.
[0083] In the above, several embodiments are described. However, the embodiments are not limited to the above embodiments, and should be understood as including various modified and alternative forms of the above-mentioned embodiments. For example, it will be understood that the various embodiments can be embodied by modifying the components without departing from the spirit and scope of the embodiments. It will also be understood that various embodiments can be implemented by appropriately combining multiple components disclosed in the above-mentioned embodiments. Furthermore, it will be understood by those skilled in the art that various embodiments can be implemented by deleting some components from all the components shown in the embodiments, or by adding some components to the components shown in the embodiments.
[0084] The following supplementary notes are further disclosed regarding the above embodiment. [Appendix 1] a reception unit that receives input of an operation for editing a program displayed on a display screen; a checking unit that, when the receiving unit receives an input of a line-of-interest change operation for changing a line of interest from a line of interest in the program to another line, executes a syntax check on the program code written in the line of interest; An information processing device comprising: [Appendix 2] The information processing device described in Appendix 1, wherein when the receiving unit receives input of the target line change operation, the inspection unit extracts the program code of the certain line from the program, and checks for syntax errors by processing the extracted program code of the certain line through a syntax checking program that checks for syntax errors. [Appendix 3] The information processing device described in Appendix 2, wherein, when the program code of the certain line includes a character string that satisfies a first condition, the inspection unit checks for syntax errors by adding to the program code of the certain line a program code of a line that satisfies a predetermined condition and is located before or after the program code of the certain line, and then having the syntax check program process it. [Appendix 4] The information processing device according to claim 2 or 3, wherein, when the certain line of program code contains a character string that satisfies a second condition, the inspection unit edits the certain line of program code and then has the program code processed by the syntax checking program to check for syntax errors. [Appendix 5] the accepting unit accepts, as the target line change operation, an operation of moving a cursor indicating an editing position of the program, which is displayed on the certain line in the program displayed on the display screen, to the other line in the program; When a syntax error is detected as a result of the syntax check, the inspection unit notifies the user of information indicating that the syntax error has been detected and the line in which the syntax error has been detected, while keeping the cursor displayed within the certain line. 5. An information processing device according to any one of claims 1 to 4. [Appendix 6] the accepting unit accepts, as the target line change operation, an operation of moving a cursor indicating an editing position of the program, which is displayed on the certain line in the program displayed on the display screen, to the other line in the program; 6. The information processing device according to claim 1, wherein the inspection unit moves the cursor to the other line when no syntax error is detected as a result of the syntax inspection. [Appendix 7] the information processing device operates in an operation mode including an edit mode in which editing of the program is accepted and an execution mode in which the program is executed; The inspection unit includes: When the operation to change the line of interest is input to the reception unit during the operation in the edit mode, a syntax check is performed on the program code written in the certain line; if an error is detected in the syntax check, allowing editing of the program code written in the certain line while operating in the edit mode; when the program code described in the certain line is edited and then the target line change operation is re-input to the reception unit, the syntax check is performed again on the edited program code described in the certain line. 7. An information processing device according to any one of claims 1 to 6. [Appendix 8] a receiving step of receiving an input of an operation for editing the program displayed on the display screen; an inspection step of executing a syntax check on the program code written in a line of interest when the input of a line of interest change operation for changing the line of interest from a line of interest in the program to another line is received by the receiving unit; An inspection method executed by an information processing device, comprising: [Appendix 9] a receiving step of receiving an input of an operation for editing the program displayed on the display screen; an inspection step of executing a syntax check on the program code written in a line of interest when the input of a line of interest change operation for changing the line of interest from a line of interest in the program to another line is received by the receiving unit; and causing an information processing device to execute a process. [Appendix 10] A server that distributes the inspection program according to claim 9. [Explanation of symbols]
[0085] 100 Information processing device 101 Key 102 Movement Keys 103 EXE Key 105 Display screen 201 Control section 202 Storage section 203 Display section 204 Input section 211 Reception 212 Inspection Department 401 Steps 501 Editing Area 502 Cursor 503 Error Information 504 Error Line 600 Computers 601 Processor 602 Memory 603 Storage device 604 Reading device 605 Removable storage media 606 Communication Interface 607 Input / Output Interface 608 Bus 611 Input Device 612 Display device 620 Network 630 Server
Claims
1. a reception unit that receives input of an operation for editing a program displayed on a display screen; an inspection unit that, when the reception unit receives an input of a line-of-interest change operation for changing a line of interest from a line of interest in the program to another line, executes a syntax inspection to inspect the program code described in the line for syntax errors; Including, The inspection unit includes: a first control for, if the program code of the certain line includes a character string that satisfies a first condition, adding a program code of a line that satisfies a predetermined condition and is located before or after the program code of the certain line to the program code of the certain line, and then executing the syntax check; or a second control for editing the program code of the certain line and then executing the syntax check if the program code of the certain line includes a character string that satisfies a second condition; Information processing device.
2. 2. The information processing device according to claim 1, wherein when the receiving unit receives input of the target line change operation, the inspection unit extracts the program code of the certain line from the program, and checks for syntax errors by processing the extracted program code of the certain line through a syntax checking program that checks for syntax errors.
3. the accepting unit accepts an input of an operation of moving a cursor indicating an editing position of the program, which is displayed on the line in the program displayed on the display screen, to the other line in the program, as the target line change operation; When a syntax error is detected as a result of the syntax check, the inspection unit notifies the user of information indicating that the syntax error has been detected and the line in which the syntax error has been detected, while keeping the cursor displayed within the line. The information processing device according to claim 1 .
4. the accepting unit accepts an input of an operation of moving a cursor indicating an editing position of the program, which is displayed on the line in the program displayed on the display screen, to the other line in the program, as the target line change operation; The information processing device according to claim 1 , wherein the checking section moves the cursor to the different line when no syntax error is detected as a result of the syntax check.
5. a reception unit that receives input of an operation for editing a program displayed on a display screen; an inspection unit that, when the reception unit receives an input of a line-of-interest change operation for changing a line of interest from a line of interest in the program to another line, executes a syntax inspection to inspect the program code described in the line for syntax errors; and an information processing apparatus that operates in an operation mode including an edit mode in which the program is edited and an execution mode in which the program is executed, The inspection unit includes: When the operation to change the line of interest is input to the reception unit during the operation in the edit mode, a syntax check is performed on the program code written in the certain line; if an error is detected in the syntax check, allowing editing of the program code written in the certain line while operating in the edit mode; when the program code described in the certain line is edited and then the target line change operation is re-input to the reception unit, the syntax check is performed again on the edited program code described in the certain line. Information processing device.
6. a receiving step of receiving an input of an operation for editing the program displayed on the display screen; a checking step of executing a syntax check to check for syntax errors in the program code written in the certain line when the receiving step receives an input of a target line change operation for changing a target line from a certain line in the program to another line; Including, The checking step performs at least one of adding, to the program code of the certain line, program code of a line that satisfies a predetermined condition and is located before or after the program code of the certain line, if the program code of the certain line includes a character string that satisfies a first condition, or editing, to the program code of the certain line, if the program code of the certain line includes a character string that satisfies a second condition, and then performs the syntax check. An inspection method executed by an information processing device.
7. a receiving step of receiving an input of an operation for editing the program displayed on the display screen; a checking step of executing a syntax check to check for syntax errors in the program code written in the certain line when an input of a line change operation for changing a line of interest from a certain line in the program is received in the receiving step; a test method executed by an information processing apparatus that operates in an operation mode including an edit mode in which the program is edited and an execution mode in which the program is executed, The inspection step includes: When the operation to change the target line is input in the receiving step during the operation in the edit mode, a syntax check is performed on the program code written in the certain line; if an error is detected in the syntax check, allowing editing of the program code written in the certain line while operating in the edit mode; when the program code written in the certain line is edited and then the target line change operation is re-input in the receiving step, the syntax check is executed again on the edited program code written in the certain line. Testing method.
8. a receiving step of receiving an input of an operation for editing the program displayed on the display screen; a checking step of executing a syntax check to check for syntax errors in the program code written in the certain line when the receiving step receives an input of a target line change operation for changing a target line from a certain line in the program to another line; causing an information processing device to execute a process including The checking step performs at least one of adding, to the program code of the certain line, program code of a line that satisfies a predetermined condition and is located before or after the program code of the certain line, if the program code of the certain line includes a character string that satisfies a first condition, or editing, to the program code of the certain line, if the program code of the certain line includes a character string that satisfies a second condition, and then performs the syntax check. Inspection program.
9. a receiving step of receiving an input of an operation for editing the program displayed on the display screen; a checking step of executing a syntax check to check for syntax errors in the program code written in the certain line when an input of a line change operation for changing a line of interest from a certain line in the program is received in the receiving step; causing an information processing device to execute a process including causing the information processing device to execute an operation mode including an edit mode for accepting editing of the program and an execution mode for executing the program; The inspection step includes: When the operation to change the target line is input in the receiving step during the operation in the edit mode, a syntax check is performed on the program code written in the certain line; if an error is detected in the syntax check, allowing editing of the program code written in the certain line while operating in the edit mode; when the program code written in the certain line is edited and then the target line change operation is re-input in the receiving step, the syntax check is executed again on the edited program code written in the certain line. Inspection program.
10. A system comprising: an information processing device; and a server that distributes the inspection program according to claim 8 to the information processing device.
Citation Information
Patent Citations
Display method for program check contents
JP1991288238A
Detecting system for error in syntax of source program
JP1996016383A
File editing device
JP1996147157A
Information processing device, information processing system, computer program, and method
JP2018037052A
Electronic equipment, display control method, and program
JP2019125055A